Use MTOM/streaming from C# calling a webservice in java exposed via jaxws
        Posted  
        
            by raticulin
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by raticulin
        
        
        
        Published on 2010-04-26T09:10:07Z
        Indexed on 
            2010/04/26
            9:13 UTC
        
        
        Read the original article
        Hit count: 1740
        
We have this webservice created with jax-ws
@WebService(name = "Mywebser", targetNamespace = "http://namespace")
@MTOM(threshold = 2048)
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class Mywebser {
    @WebMethod(operationName = "doStreaming", action = "urn:doStreaming")
    @WebResult(name = "return")
    public ResultInfo doStreaming(String username, String pwd, @XmlMimeType("application/octet-stream") DataHandler data, boolean overw){
     ...
    }
}
The generated client side looks like this:
@WebMethod(action = "urn:doStreaming")
@WebResult(targetNamespace = "")
@RequestWrapper(localName = "doStreaming", targetNamespace = "http://namespace", className = "com.mypack.client.doStreaming")
@ResponseWrapper(localName = "doStreamingResponse", targetNamespace = "http://namespace", className = "com.mypack.client.doStreamingResponse")
public ResultInfo doStreaming(
    @WebParam(name = "arg0", targetNamespace = "")
    String arg0,
    @WebParam(name = "arg1", targetNamespace = "")
    String arg1,
    @WebParam(name = "arg2", targetNamespace = "")
    DataHandler arg2,
    @WebParam(name = "arg3", targetNamespace = "")
    boolean arg3);
By using it this way it uses streaming properly (verified we can pass an argument of 80mb when the jvm had less allowed.
MywebserService serv = ...;
Mywebser wso = serv.getMywebserPort(new MTOMFeature());
Map<String, Object> ctxt = ((BindingProvider) wso).getRequestContext();
ctxt.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192);
DataHandler dataHandler = new DataHandler(new FileDataSource("c:\\temp\\A.dat"));
arcres = wso.doStreaming("a", "b", dataHandler, true);
We generate a clienet for .net, with VS2008, using "Add Web Reference", we get this C# code:
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:doStreaming",RequestNamespace="http://namespace",ResponseNamespace="http://namespace",Use=System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("return",Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public ResultInfo doStreaming(
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string arg0,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] string arg1,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified,DataType="base64Binary")] byte[] arg2,
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] bool arg3)
Apparently this is not using streaming? The type base64Binary of arg2 seems not the right one? In java it's a DataHandler. By testing it with low memory on the java side we can see it is not using streaming as it fails with OOM.
Does someone knows if this is possible, and if so how?
Our environment: server: jdk1.6, jaxws 2.1.7 client: C# 2.0, visual studio 2008
© Stack Overflow or respective owner