I'm struggling with the same/similar problem using a GSOAP generated WSDL
file with any of the popular Java SOAP stacks (Metro, Axis2, XFire, CXF,
etc...). I have a very simple interface that attempts to retrieve a "chunk"
of a file from a service by specifying a filename, file offset, and length
parameter and expecting the "chunk" to be returned via MTOM.

The "chunk" type from the GSOAP WSDL is defined as so:

  <complexType name="FileChunk">
   <annotation>
    <documentation>contains a MIME attachment</documentation>
   </annotation>
   <sequence>
     <element ref="xop:Include" minOccurs="1" maxOccurs="1"/>
   </sequence>
     <attribute ref="xmime:contentType" use="optional"/>
  </complexType>

This works fine with a GSOAP client and server. A typical transaction (GSOAP
to GSOAP) looks like this (captured with TCPMon):

REQUEST
=======

POST / HTTP/1.1
Host: 127.0.0.1:6667
User-Agent: gSOAP/2.7
Content-Type: application/soap+xml; charset=utf-8
Transfer-Encoding: chunked
Connection: close

286
<?xml version="1.0" encoding="UTF-8"?>
   <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope";
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xop="http://www.w3.org/2004/08/xop/include";
xmlns:xmime="http://www.w3.org/2005/05/xmlmime";
xmlns:hrs="urn:xmethods-HeadunitRemoteServices">
      <SOAP-ENV:Body>
         <hrs:getFileChunk>
            <filename xsi:type="xsd:string">dw.log</filename>
            <offset xsi:type="xsd:unsignedInt">0</offset>
            <length xsi:type="xsd:unsignedInt">156</length>
         </hrs:getFileChunk>
      </SOAP-ENV:Body>
   </SOAP-ENV:Envelope>0


RESPONSE
========

HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: multipart/related;
boundary="==MUVFrXVlfA8s6FhgPB4hEG/zRuy9vh7nEOLvCj2XgoLHFOAn4ccpjV+ozipy==";
type="application/xop+xml"; start="<SOAP-ENV:Envelope>";
start-info="application/soap+xml; charset=utf-8"Transfer-Encoding:
chunkedConnection: close
49C
--==MUVFrXVlfA8s6FhgPB4hEG/zRuy9vh7nEOLvCj2XgoLHFOAn4ccpjV+ozipy==
Content-Type: application/xop+xml; charset=utf-8;
type="application/soap+xml"
Content-Transfer-Encoding: binary
Content-ID: 
   <SOAP-ENV:Envelope>
      <?xml version="1.0" encoding="UTF-8"?>
         <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope";
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xop="http://www.w3.org/2004/08/xop/include";
xmlns:xmime="http://www.w3.org/2005/05/xmlmime";
xmlns:hrs="urn:xmethods-HeadunitRemoteServices">
            <SOAP-ENV:Body>
               <hrs:getFileChunkResponse>
                  <return xsi:type="hrs:FileChunk">
                     <xop:Include href="cid:id1"/>
                  </return>
               </hrs:getFileChunkResponse>
            </SOAP-ENV:Body>
        
</SOAP-ENV:Envelope>--==MUVFrXVlfA8s6FhgPB4hEG/zRuy9vh7nEOLvCj2XgoLHFOAn4ccpjV+ozipy==Content-Type:
*/*Content-Transfer-Encoding: binaryContent-ID: 
         <id1>NEW LOG13:05:20  03-12-2008ship dw20.exe 11.0.8160.0Exception
ModeNEW LOG13:06:45  03-12-2008ship dw20.exe 11.0.8160.0Exception
Mode--==MUVFrXVlfA8s6FhgPB4hEG/zRuy9vh7nEOLvCj2XgoLHFOAn4ccpjV+ozipy==--0


Unforunately, all the Java tools I've run across do not understand this (or
do not realize this request/response uses MTOM). In order to get the Java
WSDL parsers to correctly interpret this WSDL file I have to modify the type
to:

  <complexType name="FileChunk">
   <annotation>
    <documentation>contains a MIME attachment</documentation>
   </annotation>
   <sequence>
     <element name="chunk" type="xmime:base64Binary"
xmime:expectedContentType="application/octet-stream"/>
   </sequence>
  </complexType>

I created a Metro client for this WSDL using NetBeans. I also enabled MTOM
for the binding by calling:

headunitremoteservices.HeadunitRemoteServicesPort port =
service.getHeadunitRemoteServices();
javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider) port; 
javax.xml.ws.soap.SOAPBinding soapBinding = (javax.xml.ws.soap.SOAPBinding)
bp.getBinding();
soapBinding.setMTOMEnabled(true);

When I make the call I see this in TCPMon:

Metro - Call
=========

REQUEST
=======

POST / HTTP/1.1
SOAPAction: ""
Accept: application/soap+xml, multipart/related, text/html, image/gif,
image/jpeg, *; q=.2, */*; q=.2
Content-Type:
multipart/related;type="application/xop+xml";boundary="uuid:91fb86fe-d236-4c29-83aa-5f80ff2af4e0";start-info="application/soap+xml";action=""
User-Agent: Java/1.6.0_06
Host: 127.0.0.1:6667
Connection: keep-alive
Content-Length: 623

--uuid:91fb86fe-d236-4c29-83aa-5f80ff2af4e0
Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"
Content-Transfer-Encoding: binary

<?xml version="1.0" ?>
   <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope";>
      <S:Body>
         <ns3:getFileChunk xmlns:ns5="http://www.w3.org/2004/08/xop/include";
xmlns:xmime="http://www.w3.org/2005/05/xmlmime";
xmlns:ns3="urn:xmethods-HeadunitRemoteServices"
xmlns:ns1="http://www.w3.org/2003/05/soap-encoding";>
            <filename>dw.log</filename>
            <offset>0</offset>
            <length>100000</length>
         </ns3:getFileChunk>
      </S:Body>
   </S:Envelope>--uuid:91fb86fe-d236-4c29-83aa-5f80ff2af4e0--

RESPONSE
========

HTTP/1.1 200 OK
Server: gSOAP/2.7
Content-Type: multipart/related;
boundary="==eJwXq3I7ON+klwZbrIb8Zy2rwBgNOqWHSPVy1iARmQkRg61rZvwv6QBYJb0t==";
type="application/xop+xml"; start="<SOAP-ENV:Envelope>";
start-info="application/soap+xml; charset=utf-8"Transfer-Encoding:
chunkedConnection: close
49C
--==eJwXq3I7ON+klwZbrIb8Zy2rwBgNOqWHSPVy1iARmQkRg61rZvwv6QBYJb0t==
Content-Type: application/xop+xml; charset=utf-8;
type="application/soap+xml"
Content-Transfer-Encoding: binary
Content-ID: 
   <SOAP-ENV:Envelope>
      <?xml version="1.0" encoding="UTF-8"?>
         <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope";
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xop="http://www.w3.org/2004/08/xop/include";
xmlns:xmime="http://www.w3.org/2005/05/xmlmime";
xmlns:hrs="urn:xmethods-HeadunitRemoteServices">
            <SOAP-ENV:Body>
               <hrs:getFileChunkResponse>
                  <return xsi:type="hrs:FileChunk">
                     <xop:Include href="cid:id1"/>
                  </return>
               </hrs:getFileChunkResponse>
            </SOAP-ENV:Body>
        
</SOAP-ENV:Envelope>--==eJwXq3I7ON+klwZbrIb8Zy2rwBgNOqWHSPVy1iARmQkRg61rZvwv6QBYJb0t==Content-Type:
*/*Content-Transfer-Encoding: binaryContent-ID: 
         <id1>NEW LOG13:05:20  03-12-2008ship dw20.exe 11.0.8160.0Exception
ModeNEW LOG13:06:45  03-12-2008ship dw20.exe 11.0.8160.0Exception
Mode--==eJwXq3I7ON+klwZbrIb8Zy2rwBgNOqWHSPVy1iARmQkRg61rZvwv6QBYJb0t==--
0


Unfortunately, it doesn't appear the Metro client correctly parses the
returned file chunk. I get a chunk type back but it contains no data (and
there are no exceptions either). One thing to notice between the GSOAP
client call and the Metro client call is that the HTTP contentType for GSOAP
request is:

Content-Type: application/soap+xml; charset=utf-8

And the contentType for the Metro call is:

 Content-Type:
multipart/related;type="application/xop+xml";boundary="uuid:91fb86fe-d236-4c29-83aa-5f80ff2af4e0";start-info="application/soap+xml";action=""

I'm no SOAP expert but this initially caused my GSOAP server problems
because it interprets the request as having an incoming MIME component.
Previously I had call

soap_post_check_mime_attachments(mSoap);

in my GSoap C++ server so that my code explicitly handles attachments. Since
on this request I wasn't expecting an incoming attachment, it screwed up the
server. I commented out this line to let GSOAP automatically handle
attachments in order to continue testing.

So, at this point I am stuck. I can't figure out how to force the Java Metro
Client to consume the returned attachment. I'm not sure what it's looking
for in the stream or if I haven't enabled a particular option. 

Can anyone tell me what's going on here? It looks like (as far as MTOM/XOP
methods) are concerned, the GSOAP and the Java world are incompatible. My
other non-MTOM methods work fine. I just can't see how to get MTOM to work
between GSOAP and the Java toolkits.

One more note: I can use the SoapUI tools with the GSOAP WSDL file to get
file chunks. Apparently this tool does not rely on an underlying toolkit and
does the WSDL and request/response parsing itself.

Any help or suggestions would be appreciated!!!!!




Benson Margulies-4 wrote:
> 
> Perhaps more to the point, however, the error you sent indicates that your
> gsoap device is simply sending invalid XML. All the prefixes have to be
> defined, and the complaint is that 'xop:' is not defined. have you used
> logging to pull a complete copy of the XML off the wire?
> 
> 

-- 
View this message in context: 
http://www.nabble.com/MTOM-WSDL-For-Gsoap-and-CXF-tp16943667p17350144.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to