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

  1 martin 1.3 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.4 //
  3 martin 1.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 martin 1.4 //
 10 martin 1.3 // 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 martin 1.4 //
 17 martin 1.3 // The above copyright notice and this permission notice shall be included
 18            // in all copies or substantial portions of the Software.
 19 martin 1.4 //
 20 martin 1.3 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.4 // 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 martin 1.4 //
 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 kumpf  1.5 
 47 kumpf  1.2     WsmWriter::appendSoapEnvelopeStart(_envStart);
 48                WsmWriter::appendSoapEnvelopeEnd(_envEnd);
 49                WsmWriter::appendSoapHeaderStart(_hdrStart);
 50                WsmWriter::appendSoapHeaderEnd(_hdrEnd);
 51                WsmWriter::appendSoapBodyStart(_bodyStart);
 52                WsmWriter::appendSoapBodyEnd(_bodyEnd);
 53            
 54 anusha.kandepu 1.9     switch(response->getOperationType())
 55 kumpf          1.2     {
 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 rohini.deshpande 1.7         case WS_SUBSCRIPTION_CREATE:
 69                                  action = WSM_ACTION_SUBSCRIBE_RESPONSE;
 70                                  break;
 71                      
 72 kumpf            1.2         case WS_TRANSFER_DELETE:
 73                                  action = WSM_ACTION_DELETE_RESPONSE;
 74                                  break;
 75 rohini.deshpande 1.7          
 76                              case WS_SUBSCRIPTION_DELETE:
 77                                  action = WSM_ACTION_UNSUBSCRIBE_RESPONSE;
 78                                  break;    
 79                           
 80 kumpf            1.2         case WS_ENUMERATION_ENUMERATE:
 81                                  action = WSM_ACTION_ENUMERATE_RESPONSE;
 82                                  break;
 83                      
 84                              case WS_ENUMERATION_PULL:
 85                                  action = WSM_ACTION_PULL_RESPONSE;
 86                                  break;
 87                      
 88                              case WS_ENUMERATION_RELEASE:
 89                                  action = WSM_ACTION_RELEASE_RESPONSE;
 90                                  break;
 91                      
 92                              case WSM_FAULT:
 93                                  action = ((WsmFaultResponse*) response)->getFault().getAction();
 94 kumpf            1.5             WsmWriter::appendSoapHeader(_hdrContent,
 95 kumpf            1.2                 action, response->getMessageId(), response->getRelatesTo());
 96 kumpf            1.5             WsmWriter::appendWsmFaultBody(_bodyContent,
 97 kumpf            1.2                 ((WsmFaultResponse*) response)->getFault());
 98                                  break;
 99                      
100                              case SOAP_FAULT:
101                                  action = String(WsmNamespaces::supportedNamespaces[
102                                      WsmNamespaces::WS_ADDRESSING].extendedName) + String("/fault");
103 kumpf            1.5             WsmWriter::appendSoapFaultHeaders(_hdrContent,
104 kumpf            1.2                 ((SoapFaultResponse*) response)->getFault(),
105                                      action, response->getMessageId(), response->getRelatesTo());
106 kumpf            1.5             WsmWriter::appendSoapFaultBody(_bodyContent,
107 kumpf            1.2                 ((SoapFaultResponse*) response)->getFault());
108                                  break;
109                      
110 mike             1.6         case WS_INVOKE:
111                              {
112                                  WsInvokeResponse* rsp = (WsInvokeResponse*)response;
113                      
114                                  // Get root of resource URI.
115                                  String root = WsmUtils::getRootResourceUri(rsp->resourceUri);
116                      
117                                  // Build the action.
118                                  action = root;
119                                  action.append('/');
120                                  action.append(rsp->className);
121                                  action.append('/');
122                                  action.append(rsp->methodName);
123                                  break;
124                              }
125                      
126 kumpf            1.2         default:
127 dl.meetei        1.8             PEGASUS_UNREACHABLE(PEGASUS_ASSERT(0);)
128 kumpf            1.2     }
129                      
130 kumpf            1.5     WsmWriter::appendHTTPResponseHeader(_httpHeader, action,
131 mike             1.6        response->getHttpMethod(), response->getOmitXMLProcessingInstruction(),
132                             response->getContentLanguages(),
133 anusha.kandepu   1.9        response->getOperationType() == WSM_FAULT || 
134                                 response->getOperationType() == SOAP_FAULT,0);
135 kumpf            1.2 
136                          // Make sure that fault response fits within MaxEnvelopeSize
137 anusha.kandepu   1.9     if (response->getOperationType() == WSM_FAULT || 
138                              response->getOperationType() == SOAP_FAULT)
139 kumpf            1.2     {
140                              if (_maxEnvelopeSize && getEnvelopeSize() > _maxEnvelopeSize)
141                              {
142                                  _bodyContent.clear();
143                                  WsmFault fault(WsmFault::wsman_EncodingLimit,
144                                      MessageLoaderParms(
145                                          "WsmServer.WsmResponseEncoder.FAULT_MAX_ENV_SIZE_EXCEEDED",
146                                          "Fault response could not be encoded within requested "
147                                          "envelope size limits."),
148                                      WSMAN_FAULTDETAIL_MAXENVELOPESIZE);
149                                  WsmWriter::appendWsmFaultBody(_bodyContent, fault);
150                              }
151                          }
152                          else
153                          {
154 kumpf            1.5         WsmWriter::appendSoapHeader(_hdrContent,
155 kumpf            1.2             action, response->getMessageId(), response->getRelatesTo());
156                          }
157                      }
158                      
159                      Buffer SoapResponse::getResponseContent()
160                      {
161                          Buffer out(WSM_MIN_MAXENVELOPESIZE_VALUE);
162 kumpf            1.5     out << _httpHeader << _envStart << _hdrStart << _hdrContent
163                              << _hdrEnd << _bodyStart << _bodyHeader << _bodyContent
164 kumpf            1.2         << _bodyTrailer << _bodyEnd << _envEnd;
165                          return out;
166                      }
167                      
168                      Boolean SoapResponse::appendHeader(Buffer& buf)
169                      {
170 kumpf            1.5     if (_maxEnvelopeSize &&
171 kumpf            1.2         getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
172                          {
173                              return false;
174                          }
175                          _hdrContent << buf;
176                          return true;
177                      }
178                      
179                      Boolean SoapResponse::appendBodyContent(Buffer& buf)
180                      {
181 kumpf            1.5     if (_maxEnvelopeSize &&
182 kumpf            1.2         getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
183                          {
184                              return false;
185                          }
186                          _bodyContent << buf;
187                          return true;
188                      }
189                      
190                      Boolean SoapResponse::appendBodyHeader(Buffer& buf)
191                      {
192 kumpf            1.5     if (_maxEnvelopeSize &&
193 kumpf            1.2         getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
194                          {
195                              return false;
196                          }
197                          _bodyHeader << buf;
198                          return true;
199                      }
200                      
201                      Boolean SoapResponse::appendBodyTrailer(Buffer& buf)
202                      {
203 kumpf            1.5     if (_maxEnvelopeSize &&
204 kumpf            1.2         getEnvelopeSize() + buf.size() > _maxEnvelopeSize)
205                          {
206                              return false;
207                          }
208                          _bodyTrailer << buf;
209                          return true;
210                      }
211                      
212                      PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2