users@jax-ws.java.net

Re: JWSDP 2.0 mtom soap 1.2 interoperability issue - need help

From: Vivek Pandey <Vivek.Pandey_at_Sun.COM>
Date: Thu, 02 Mar 2006 06:34:20 +0100

[moved to users_at_jax-ws.dev.java.net]

 From the stack trace it appears that .NET server doesnt like the jaxws
client REQUEST. Its because .net service once configured for MTOM throws
400 Bad Request. This happens because unlike .NET JAXWS applies MTOM
encoding only when binary optimization is applied on the message.

This happesn if the message payload/header has binary data in it
(xs:base64Binary) and the data is > 1KB. 1KB size is modifiable. You can
change it to lets say 0KB in that case all the request/response will be
MTOM encoded provided they have binary data in it.

see
https://jax-ws.dev.java.net/jax-ws-ea3/docs/mtom-swaref.html#2.3_Attach_vs_In-line
which describes how to change the threshold.

for example:


      |bindingProvider.getRequestContext().put(JAXWSProperties.MTOM_THRESHOLD_VALUE,
      0);|

will change the default threashold form 1KB to 0.

If it doesnt fix your problem please send the HTTP traffic, you may use
HttpSpy or Ethereal.


-vivek.


Ray Lai wrote:
> Dear all:
>
> I'm writing a Java client using JWSDP 2.0 with MTOM SOAP 1.2 to invoke
> a remote .NET service, which provides binary file download using MTOM
> SOAP 1.2. The Java client fetches a binary file (e.g. a jpg file) and
> writes a copy to the local c:\tmp. I encounter some problems in JAX-WS
> client to interpret the MTOM payload. The MTOM client complains a HTTP
> 400 error, which I suspect from the error messages that the MTOM
> client cannot read the MTOM encoded content (which is a jpg file in
> this example).
>
> I can test the SOAP message (in base64 encoded message, see the
> details below) provided by the WSDL. In other words, the .NET service
> should be working OK. The Java client compiles OK, but has runtime
> error (refer to the error messages below).
>
> Do you have any suggestion which may go wrong? Did I miss anything in
> the Java client configuration? Any pointer or suggestion will be helpful.
>
> Thanks.
> rgds, ray
>
> =====================
> Mtom with SOAP 1.2 getFileBinary Service from .NET Server:
>
> WSDL: http://localhost:4891/WebSite2/Service.asmx?wsdl
>
> <?xml version="1.0" encoding="utf-8"?>
> <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
> xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
> xmlns:tns="http://tempuri.org/"
> xmlns:s="http://www.w3.org/2001/XMLSchema"
> xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
> xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
> targetNamespace="http://tempuri.org/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
> <wsdl:types>
> <s:schema elementFormDefault="qualified"
> targetNamespace="http://tempuri.org/">
> <s:element name="GetFileBinary">
> <s:complexType>
> <s:sequence>
> <s:element minOccurs="0" maxOccurs="1" name="fileName"
> type="s:string" />
> </s:sequence>
> </s:complexType>
> </s:element>
> <s:element name="GetFileBinaryResponse">
> <s:complexType>
> <s:sequence>
> <s:element minOccurs="0" maxOccurs="1"
> name="GetFileBinaryResult" type="s:base64Binary" />
> </s:sequence>
> </s:complexType>
> </s:element>
> </s:schema>
> </wsdl:types>
> <wsdl:message name="GetFileBinarySoapIn">
> <wsdl:part name="parameters" element="tns:GetFileBinary" />
> </wsdl:message>
> <wsdl:message name="GetFileBinarySoapOut">
> <wsdl:part name="parameters" element="tns:GetFileBinaryResponse" />
> </wsdl:message>
> <wsdl:portType name="ServiceSoap">
> <wsdl:operation name="GetFileBinary">
> <wsdl:input message="tns:GetFileBinarySoapIn" />
> <wsdl:output message="tns:GetFileBinarySoapOut" />
> </wsdl:operation>
> </wsdl:portType>
> <wsdl:binding name="ServiceSoap" type="tns:ServiceSoap">
> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
> <wsdl:operation name="GetFileBinary">
> <soap:operation soapAction="http://tempuri.org/GetFileBinary"
> style="document" />
> <wsdl:input>
> <soap:body use="literal" />
> </wsdl:input>
> <wsdl:output>
> <soap:body use="literal" />
> </wsdl:output>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:binding name="ServiceSoap12" type="tns:ServiceSoap">
> <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
> <wsdl:operation name="GetFileBinary">
> <soap12:operation soapAction="http://tempuri.org/GetFileBinary"
> style="document" />
> <wsdl:input>
> <soap12:body use="literal" />
> </wsdl:input>
> <wsdl:output>
> <soap12:body use="literal" />
> </wsdl:output>
> </wsdl:operation>
> </wsdl:binding>
> <wsdl:service name="Service">
> <wsdl:port name="ServiceSoap" binding="tns:ServiceSoap">
> <soap:address
> location="http://localhost:4891/WebSite2/Service.asmx" />
> </wsdl:port>
> <wsdl:port name="ServiceSoap12" binding="tns:ServiceSoap12">
> <soap12:address
> location="http://localhost:4891/WebSite2/Service.asmx" />
> </wsdl:port>
> </wsdl:service>
> </wsdl:definitions>
>
> Invoking the URL
> http://localhost:4891/WebSite2/Service.asmx/GetFileBinary will return
> the following SOAP message:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <base64Binary
> xmlns="http://tempuri.org/">/9j/4AAQSkZJRgABAgEASABIAAD/5PxZumk4zHanByR1ZqDqzVkjMKSY5jtTgRJyK
>
> ...
> drjD9D2N3cEdQMRCROki2n3Ypeq3de0Y6gSGIYZL89Qr9ScYfaAG2CbEBfFIQfbio45oYXe6+IQg+3CrS1Sam+S+GQg//9k=</base64Binary>
>
>
> =====================
> Java client source code:
>
> import com.javadotnet.interop.generated.*;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import javax.xml.ws.BindingProvider;
> import javax.xml.ws.soap.SOAPBinding;
>
> public class DotNetWSClient {
>
> /** Creates a new instance of DotNetWSClient */
> public DotNetWSClient() {
>
> ServiceSoap port = new Service().getServiceSoap12();
>
> SOAPBinding binding =
> (SOAPBinding)((BindingProvider)port).getBinding();
> binding.setMTOMEnabled(true);
>
>
> try {
> byte[] fileData = port.getFileBinary("Home.jpg");
>
> FileOutputStream fos = new
> FileOutputStream("C:\\tmp\\Home.jpg");
> fos.write(fileData);
> fos.flush();
> fos.close();
> } catch (IOException ex) {
> ex.printStackTrace();
> }
> }
>
> public static void main(String args[]) {
> new DotNetWSClient();
> }
>
> }
>
> ===================
>
>
> Running from Command Prompt:
>
> C:\dev\DotNetWSClient2\dist>java -cp
> ./DotNetWSClient2.jar;C:\tools\jaxws\lib\ja
> xws-api.jar;C:\tools\jaxws\lib\jaxws-rt.jar;C:\tools\jaxws\lib\jaxws-tools.jar
> c
> om.javadotnet.interop.DotNetWSClient
> Exception in thread "main" javax.xml.ws.WebServiceException:
> unexpected XML read
> er state. expected: END_ELEMENT but found: CHARACTERS
> at
> com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toInternalMessage(
> SOAPXMLDecoder.java:263)
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOA
> PMessageDispatcher.java:529)
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAP
> MessageDispatcher.java:253)
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMe
> ssageDispatcher.java:112)
> at
> com.sun.xml.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.
> java:84)
> at
> com.sun.xml.ws.client.EndpointIFInvocationHandler.implementSEIMethod(
> EndpointIFInvocationHandler.java:171)
> at
> com.sun.xml.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFIn
> vocationHandler.java:105)
> at $Proxy18.getFileBinary(Unknown Source)
> at
> com.javadotnet.interop.DotNetWSClient.<init>(DotNetWSClient.java:38)
> at
> com.javadotnet.interop.DotNetWSClient.main(DotNetWSClient.java:56)
> Caused by: unexpected XML reader state. expected: END_ELEMENT but
> found: CHARACT
> ERS
> at
> com.sun.xml.ws.streaming.XMLStreamReaderUtil.verifyReaderState(XMLStr
> eamReaderUtil.java:193)
> at
> com.sun.xml.ws.encoding.soap.client.SOAP12XMLDecoder.readFaultReasonT
> exts(SOAP12XMLDecoder.java:214)
> at
> com.sun.xml.ws.encoding.soap.client.SOAP12XMLDecoder.readFaultReason(
> SOAP12XMLDecoder.java:185)
> at
> com.sun.xml.ws.encoding.soap.client.SOAP12XMLDecoder.decodeFault(SOAP
> 12XMLDecoder.java:104)
> at
> com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBodyContent(SOAPDecode
> r.java:340)
> at
> com.sun.xml.ws.encoding.soap.SOAPDecoder.decodeBody(SOAPDecoder.java:
> 325)
> at
> com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.decodeBody(SOAPXML
> Decoder.java:188)
> at
> com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.decodeEnvelope(SOA
> PXMLDecoder.java:139)
> at
> com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toInternalMessage(
> SOAPXMLDecoder.java:256)
> ... 9 more
>
>
> Running from NetBeans 5.0 IDE:
>
> init:
> deps-jar:
> running wsimport
> warning: SOAP port "ServiceSoap12": uses a non-standard SOAP 1.2 binding.
>
> compile:
> run:
> HTTP Status-Code 400: Bad Request
> at
> com.sun.xml.ws.transport.http.client.HttpClientTransport.checkResponseCode(HttpClientTransport.java:300)
>
> at
> com.sun.xml.ws.transport.http.client.HttpClientTransport.getHeaders(HttpClientTransport.java:153)
>
> at
> com.sun.xml.ws.util.SOAPConnectionUtil.getSOAPMessage(SOAPConnectionUtil.java:58)
>
> at
> com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toSOAPMessage(SOAPXMLDecoder.java:97)
>
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:459)
>
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAPMessageDispatcher.java:291)
>
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMessageDispatcher.java:157)
>
> at
> com.sun.xml.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.java:85)
>
> at
> com.sun.xml.ws.client.EndpointIFInvocationHandler.implementSEIMethod(EndpointIFInvocationHandler.java:177)
>
> at
> com.sun.xml.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFInvocationHandler.java:105)
>
> at $Proxy24.getFileBinary(Unknown Source)
> at
> com.javadotnet.interop.DotNetWSClient.<init>(DotNetWSClient.java:38)
> at
> com.javadotnet.interop.DotNetWSClient.main(DotNetWSClient.java:56)
> Exception in thread "main" javax.xml.ws.WebServiceException: HTTP
> Status-Code 400: Bad Request
> at
> com.sun.xml.ws.util.SOAPConnectionUtil.getSOAPMessage(SOAPConnectionUtil.java:82)
>
> at
> com.sun.xml.ws.encoding.soap.client.SOAPXMLDecoder.toSOAPMessage(SOAPXMLDecoder.java:97)
>
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:459)
>
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.doSend(SOAPMessageDispatcher.java:291)
>
> at
> com.sun.xml.ws.protocol.soap.client.SOAPMessageDispatcher.send(SOAPMessageDispatcher.java:157)
>
> at
> com.sun.xml.ws.encoding.soap.internal.DelegateBase.send(DelegateBase.java:85)
>
> at
> com.sun.xml.ws.client.EndpointIFInvocationHandler.implementSEIMethod(EndpointIFInvocationHandler.java:177)
>
> at
> com.sun.xml.ws.client.EndpointIFInvocationHandler.invoke(EndpointIFInvocationHandler.java:105)
>
> at $Proxy24.getFileBinary(Unknown Source)
> at
> com.javadotnet.interop.DotNetWSClient.<init>(DotNetWSClient.java:38)
> at
> com.javadotnet.interop.DotNetWSClient.main(DotNetWSClient.java:56)
> Caused by: HTTP Status-Code 400: Bad Request
> at
> com.sun.xml.ws.transport.http.client.HttpClientTransport.checkResponseCode(HttpClientTransport.java:300)
>
> at
> com.sun.xml.ws.transport.http.client.HttpClientTransport.getHeaders(HttpClientTransport.java:153)
>
> at
> com.sun.xml.ws.util.SOAPConnectionUtil.getSOAPMessage(SOAPConnectionUtil.java:58)
>
> ... 10 more
> Java Result: 1
> BUILD SUCCESSFUL (total time: 7 seconds)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jwsdp.dev.java.net
> For additional commands, e-mail: users-help_at_jwsdp.dev.java.net
>

-- 
Vivek Pandey
Web Services Standards and Technologies
Sun Microsystems Inc.