You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Anand Natrajan <an...@cs.virginia.edu> on 2004/08/25 23:34:27 UTC
What's the right WSDL for MIME?
All,
I have a web service implemented in Java using Axis. In this service, I have
a method that takes some simple params and returns a single attachment.
Following the Axis examples, I have defined the signature of this method as:
public DataHandler fileReadAttach(AvakiPrincipal principal, String path,
long offset, int count)
throws RemoteException;
Then, I use java2wsdl wrapped/literal to generate a WSDL for this. The
relevant parts of the WSDL are as below:
<element name="fileReadAttachResponse">
<complexType>
<sequence>
<element name="fileReadAttachReturn"
type="apachesoap:DataHandler"/>
</sequence>
</complexType>
</element>
...
<wsdl:operation name="fileReadAttach">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="fileReadAttachRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="fileReadAttachResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
Notice how the attachment refers to an apache:DataHandler element. This
works without a problem when I write Java/Axis clients that target this
service. However, .NET won't even swallow the WSDL because it does not
recognise the apachesoap namespace.
My question is: why isn't the generated WSDL something like:
<wsdl:operation name="fileReadAttach">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="fileReadAttachRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="fileReadAttachResponse">
<mime:multipartRelated>
<mime:part>
<wsdlsoap:body parts="body" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="docs" type="text/plain"/>
</mime:part>
</mime:multipartRelated>
</wsdl:output>
</wsdl:operation>
Seems to me that's how it should come out. How do I make it so?
For giggles, I changed the WSDL by hand and tried to generate stubs for it.
wsdl2java failed to do so, with a NullPointerException:
[axis-wsdl2java] WSDL2Java
/home/local/anand/System/Jabc/wsdl/MyServiceWithMIMEDocLit.wsdl
[axis-wsdl2java] Running Wsdl2javaAntTask with parameters:
[axis-wsdl2java] verbose:false
[axis-wsdl2java] debug:false
[axis-wsdl2java] quiet:false
[axis-wsdl2java] server-side:true
[axis-wsdl2java] skeletonDeploy:false
[axis-wsdl2java] helperGen:false
[axis-wsdl2java] factory:null
[axis-wsdl2java] nsIncludes:[]
[axis-wsdl2java] nsExcludes:[]
[axis-wsdl2java] factoryProps:[]
[axis-wsdl2java] testCase:false
[axis-wsdl2java] noImports:false
[axis-wsdl2java] NStoPkg:{urn:MyServiceCommon=com.abc.api.common.doclit, urn:MyServiceWithMIMEDocLit=com.abc.ws.stubs}
[axis-wsdl2java] output:/home/local/anand/System/Jabc/wsdl
[axis-wsdl2java] protocolHandlerPkgs:
[axis-wsdl2java] deployScope:
[axis-wsdl2java] URL:/home/local/anand/System/Jabc/wsdl/MyServiceWithMIMEDocLit.wsdl
[axis-wsdl2java] all:false
[axis-wsdl2java] typeMappingVersion:1.1
[axis-wsdl2java] timeout:45000
[axis-wsdl2java] failOnNetworkErrors:false
[axis-wsdl2java] printStackTraceOnFailure:true
[axis-wsdl2java] namespaceMappingFile:null
[axis-wsdl2java] username:null
[axis-wsdl2java] :passwordnull
[axis-wsdl2java] :noWrappedfalse
[axis-wsdl2java] :implementationClassNamenull
[axis-wsdl2java] :classpathnull
[axis-wsdl2java] http.proxyHost=null
[axis-wsdl2java] http.proxyPort=null
[axis-wsdl2java] http.proxyUser=null
[axis-wsdl2java] http.proxyPassword=null
[axis-wsdl2java] socks.proxyHost=null
[axis-wsdl2java] socks.proxyPort=null
[axis-wsdl2java] java.lang.NullPointerException
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.addMIMETypes(SymbolTable.java:2864)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.fillInBindingInfo(SymbolTable.java:2544)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings(SymbolTable.java:2464)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:731)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:531)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:506)
[axis-wsdl2java] at org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:483)
[axis-wsdl2java] at org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:356)
[axis-wsdl2java] at java.lang.Thread.run(Thread.java:534)
Any idea why Axis is failing on what looks like a legitimate WSDL? Should I
open a bug? Thanks!
Anand
RE: What's the right WSDL for MIME?
Posted by Anne Thomas Manes <an...@manes.net>.
Btw -- WS-I just published the Attachments Profile [1].
Here's an example of a correct WSDL description for document/literal
binding. Note that Axis should not be using the apachesoap:dataHandler
datatype. Also note that even though the binding is doc/literal, the MIME
attachment message parts must be defined as types (type="xsd:base64binary")
rather than as elements.
<?xml version="1.0" encoding="utf-8" ?>
<wsdl:definitions xmlns:types="http://example.com/mimetypes"
xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="http://example.com/mimewsdl"
xmlns:tns="http://example.com/mimewsdl">
<wsdl:types>
<xsd:schema targetNamespace="http://example.com/mimetypes"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://ws-i.org/profiles/basic/1.1/xsd"
/>
<xsd:element name="ClaimDetail" type="types:ClaimDetailType"/>
<xsd:complexType name="ClaimDetailType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="ClaimForm" type="ref:swaRef"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="ClaimRefNo" type="xsd:string"/>
</xsd:schema>
</wsdl:types>
<wsdl:message name="ClaimIn">
<wsdl:part name="body" element="types:ClaimDetail"/>
<wsdl:part name="ClaimPhoto" type="xsd:base64Binary"/>
</wsdl:message>
<wsdl:message name="ClaimOut">
<wsdl:part name="out" element="types:ClaimRefNo"/>
</wsdl:message>
<wsdl:portType name="ClaimPortType">
<wsdl:operation name="SendClaim">
<wsdl:input message="tns:ClaimIn"/>
<wsdl:output message="tns:ClaimOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ClaimBinding" type="tns:ClaimPortType">
<soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="SendClaim">
<soapbind:operation soapAction="http://example.com/soapaction"/>
<wsdl:input>
<mime:multipartRelated>
<mime:part>
<soapbind:body parts="body" use="literal"/>
</mime:part>
<mime:part>
<mime:content part="ClaimPhoto" type="image/jpeg"/>
</mime:part>
</mime:multipartRelated>
</wsdl:input>
<wsdl:output>
<soapbind:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
[1] http://www.ws-i.org/Profiles/AttachmentsProfile-1.0-2004-08-24.html
-----Original Message-----
From: Anand Natrajan [mailto:an4m@cs.virginia.edu]
Sent: Wednesday, August 25, 2004 5:34 PM
To: axis-user@ws.apache.org
Subject: What's the right WSDL for MIME?
All,
I have a web service implemented in Java using Axis. In this service, I have
a method that takes some simple params and returns a single attachment.
Following the Axis examples, I have defined the signature of this method as:
public DataHandler fileReadAttach(AvakiPrincipal principal, String
path,
long offset, int count)
throws RemoteException;
Then, I use java2wsdl wrapped/literal to generate a WSDL for this. The
relevant parts of the WSDL are as below:
<element name="fileReadAttachResponse">
<complexType>
<sequence>
<element name="fileReadAttachReturn"
type="apachesoap:DataHandler"/>
</sequence>
</complexType>
</element>
...
<wsdl:operation name="fileReadAttach">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="fileReadAttachRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="fileReadAttachResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
Notice how the attachment refers to an apache:DataHandler element. This
works without a problem when I write Java/Axis clients that target this
service. However, .NET won't even swallow the WSDL because it does not
recognise the apachesoap namespace.
My question is: why isn't the generated WSDL something like:
<wsdl:operation name="fileReadAttach">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="fileReadAttachRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="fileReadAttachResponse">
<mime:multipartRelated>
<mime:part>
<wsdlsoap:body parts="body"
use="literal"/>
</mime:part>
<mime:part>
<mime:content part="docs"
type="text/plain"/>
</mime:part>
</mime:multipartRelated>
</wsdl:output>
</wsdl:operation>
Seems to me that's how it should come out. How do I make it so?
For giggles, I changed the WSDL by hand and tried to generate stubs for it.
wsdl2java failed to do so, with a NullPointerException:
[axis-wsdl2java] WSDL2Java
/home/local/anand/System/Jabc/wsdl/MyServiceWithMIMEDocLit.wsdl
[axis-wsdl2java] Running Wsdl2javaAntTask with parameters:
[axis-wsdl2java] verbose:false
[axis-wsdl2java] debug:false
[axis-wsdl2java] quiet:false
[axis-wsdl2java] server-side:true
[axis-wsdl2java] skeletonDeploy:false
[axis-wsdl2java] helperGen:false
[axis-wsdl2java] factory:null
[axis-wsdl2java] nsIncludes:[]
[axis-wsdl2java] nsExcludes:[]
[axis-wsdl2java] factoryProps:[]
[axis-wsdl2java] testCase:false
[axis-wsdl2java] noImports:false
[axis-wsdl2java]
NStoPkg:{urn:MyServiceCommon=com.abc.api.common.doclit,
urn:MyServiceWithMIMEDocLit=com.abc.ws.stubs}
[axis-wsdl2java] output:/home/local/anand/System/Jabc/wsdl
[axis-wsdl2java] protocolHandlerPkgs:
[axis-wsdl2java] deployScope:
[axis-wsdl2java]
URL:/home/local/anand/System/Jabc/wsdl/MyServiceWithMIMEDocLit.wsdl
[axis-wsdl2java] all:false
[axis-wsdl2java] typeMappingVersion:1.1
[axis-wsdl2java] timeout:45000
[axis-wsdl2java] failOnNetworkErrors:false
[axis-wsdl2java] printStackTraceOnFailure:true
[axis-wsdl2java] namespaceMappingFile:null
[axis-wsdl2java] username:null
[axis-wsdl2java] :passwordnull
[axis-wsdl2java] :noWrappedfalse
[axis-wsdl2java] :implementationClassNamenull
[axis-wsdl2java] :classpathnull
[axis-wsdl2java] http.proxyHost=null
[axis-wsdl2java] http.proxyPort=null
[axis-wsdl2java] http.proxyUser=null
[axis-wsdl2java] http.proxyPassword=null
[axis-wsdl2java] socks.proxyHost=null
[axis-wsdl2java] socks.proxyPort=null
[axis-wsdl2java] java.lang.NullPointerException
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.addMIMETypes(SymbolTable.java:2
864)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.fillInBindingInfo(SymbolTable.j
ava:2544)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings(SymbolTable.ja
va:2464)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:731)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:531)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:506)
[axis-wsdl2java] at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:483)
[axis-wsdl2java] at
org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:356)
[axis-wsdl2java] at java.lang.Thread.run(Thread.java:534)
Any idea why Axis is failing on what looks like a legitimate WSDL? Should I
open a bug? Thanks!
Anand