(file) Return to SoapResponse.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / WsmServer

  1 martin 1.3 //%LICENSE////////////////////////////////////////////////////////////////
  2            // 
  3            // Licensed to The Open Group (TOG) under one or more contributor license
  4            // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5            // this work for additional information regarding copyright ownership.
  6            // Each contributor licenses this file to you under the OpenPegasus Open
  7            // Source License; you may not use this file except in compliance with the
  8            // License.
  9            // 
 10            // Permission is hereby granted, free of charge, to any person obtaining a
 11            // copy of this software and associated documentation files (the "Software"),
 12            // to deal in the Software without restriction, including without limitation
 13            // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14            // and/or sell copies of the Software, and to permit persons to whom the
 15            // Software is furnished to do so, subject to the following conditions:
 16            // 
 17            // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19            // 
 20            // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21            // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 22 martin 1.3 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23            // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24            // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25            // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26            // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 kumpf  1.2 // 
 28 martin 1.3 //////////////////////////////////////////////////////////////////////////
 29 kumpf  1.2 //
 30            //%/////////////////////////////////////////////////////////////////////////////
 31            #include "SoapResponse.h"
 32            #include "WsmWriter.h"
 33            
 34            PEGASUS_USING_STD;
 35            
 36            PEGASUS_NAMESPACE_BEGIN
 37            
 38            SoapResponse::SoapResponse(WsmResponse* response)
 39            {
 40                String action;
 41                ContentLanguageList lang;
 42            
 43                _maxEnvelopeSize = response->getMaxEnvelopeSize();
 44                _queueId = response->getQueueId();
 45                _httpCloseConnect = response->getHttpCloseConnect();
 46                
 47                WsmWriter::appendSoapEnvelopeStart(_envStart);
 48                WsmWriter::appendSoapEnvelopeEnd(_envEnd);
 49                WsmWriter::appendSoapHeaderStart(_hdrStart);
 50 kumpf  1.2     WsmWriter::appendSoapHeaderEnd(_hdrEnd);
 51                WsmWriter::appendSoapBodyStart(_bodyStart);
 52                WsmWriter::appendSoapBodyEnd(_bodyEnd);
 53            
 54                switch(response->getType())
 55                {
 56                    case WS_TRANSFER_GET:
 57                        action = WSM_ACTION_GET_RESPONSE;
 58                        break;
 59            
 60                    case WS_TRANSFER_PUT:
 61                        action = WSM_ACTION_PUT_RESPONSE;
 62                        break;
 63            
 64                    case WS_TRANSFER_CREATE:
 65                        action = WSM_ACTION_CREATE_RESPONSE;
 66                        break;
 67            
 68                    case WS_TRANSFER_DELETE:
 69                        action = WSM_ACTION_DELETE_RESPONSE;
 70                        break;
 71 kumpf  1.2 
 72                    case WS_ENUMERATION_ENUMERATE:
 73                        action = WSM_ACTION_ENUMERATE_RESPONSE;
 74                        break;
 75            
 76                    case WS_ENUMERATION_PULL:
 77                        action = WSM_ACTION_PULL_RESPONSE;
 78                        break;
 79            
 80                    case WS_ENUMERATION_RELEASE:
 81                        action = WSM_ACTION_RELEASE_RESPONSE;
 82                        break;
 83            
 84                    case WSM_FAULT:
 85                        action = ((WsmFaultResponse*) response)->getFault().getAction();
 86                        WsmWriter::appendSoapHeader(_hdrContent, 
 87                            action, response->getMessageId(), response->getRelatesTo());
 88                        WsmWriter::appendWsmFaultBody(_bodyContent, 
 89                            ((WsmFaultResponse*) response)->getFault());
 90                        break;
 91            
 92 kumpf  1.2         case SOAP_FAULT:
 93                        action = String(WsmNamespaces::supportedNamespaces[
 94                            WsmNamespaces::WS_ADDRESSING].extendedName) + String("/fault");
 95                        WsmWriter::appendSoapFaultHeaders(_hdrContent, 
 96                            ((SoapFaultResponse*) response)->getFault(),
 97                            action, response->getMessageId(), response->getRelatesTo());
 98                        WsmWriter::appendSoapFaultBody(_bodyContent, 
 99                            ((SoapFaultResponse*) response)->getFault());
100                        break;
101            
102                    default:
103                        PEGASUS_ASSERT(0);
104                }
105            
106                WsmWriter::appendHTTPResponseHeader(_httpHeader, action, 
107                   response->getHttpMethod(), response->getContentLanguages(), 
108                   response->getType() == WSM_FAULT || response->getType() == SOAP_FAULT,
109                   0);
110            
111                // Make sure that fault response fits within MaxEnvelopeSize
112                if (response->getType() == WSM_FAULT || response->getType() == SOAP_FAULT)
113 kumpf  1.2     {
114                    if (_maxEnvelopeSize && getEnvelopeSize() > _maxEnvelopeSize)
115                    {
116                        _bodyContent.clear();
117                        WsmFault fault(WsmFault::wsman_EncodingLimit,
118                            MessageLoaderParms(
119                                "WsmServer.WsmResponseEncoder.FAULT_MAX_ENV_SIZE_EXCEEDED",
120                                "Fault response could not be encoded within requested "
121                                "envelope size limits."),
122                            WSMAN_FAULTDETAIL_MAXENVELOPESIZE);
123                        WsmWriter::appendWsmFaultBody(_bodyContent, fault);
124                    }
125                }
126                else
127                {
128                    WsmWriter::appendSoapHeader(_hdrContent, 
129                        action, response->getMessageId(), response->getRelatesTo());
130                }
131            }
132            
133            Buffer SoapResponse::getResponseContent()
134 kumpf  1.2 {
135                Buffer out(WSM_MIN_MAXENVELOPESIZE_VALUE);
136                out << _httpHeader << _envStart << _hdrStart << _hdrContent 
137                    << _hdrEnd << _bodyStart << _bodyHeader << _bodyContent 
138                    << _bodyTrailer << _bodyEnd << _envEnd;
139                return out;
140            }
141            
142            Boolean SoapResponse::appendHeader(Buffer& buf)
143            {
144                if (_maxEnvelopeSize && 
145                    getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
146                {
147                    return false;
148                }
149                _hdrContent << buf;
150                return true;
151            }
152            
153            Boolean SoapResponse::appendBodyContent(Buffer& buf)
154            {
155 kumpf  1.2     if (_maxEnvelopeSize && 
156                    getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
157                {
158                    return false;
159                }
160                _bodyContent << buf;
161                return true;
162            }
163            
164            Boolean SoapResponse::appendBodyHeader(Buffer& buf)
165            {
166                if (_maxEnvelopeSize && 
167                    getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
168                {
169                    return false;
170                }
171                _bodyHeader << buf;
172                return true;
173            }
174            
175            Boolean SoapResponse::appendBodyTrailer(Buffer& buf)
176 kumpf  1.2 {
177                if (_maxEnvelopeSize && 
178                    getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
179                {
180                    return false;
181                }
182                _bodyTrailer << buf;
183                return true;
184            }
185            
186            PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2