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 William Bug <Wi...@drexel.edu> on 2004/04/02 02:15:08 UTC
WSDL2Java - can't use mime:multipartRelated in wsdl:output element
Hi All,
I'm having trouble creating an appropriate WSDL file to create a
service that returns a large set of binary attachments.
I've been trying to combine what I could pull from the documentation on
WSDL2Java with the info in the very useful article:
Web services programming tips and tricks: SOAP attachments with JAX-RPC
http://www-106.ibm.com/developerworks/webservices/library/ws-tip-
soapjax.html
So far, I've not been successful.
I've got an original implementation in SAAJ that works, but the code is
much more complicated than it would be had I used JAX-RPC attachments
as described in the article listed above.
I created a very simple Interface that I ran through Java2WSDL to
create my WSDL file.
The Interface is as follows:
<snippet>
import java.io.File;
import java.rmi.Remote;
import java.rmi.RemoteException;
/**
*
* @author billbug
*/
public interface IRepositoryAccess extends Remote {
public File[] getImages(Boolean returnZip, String imageSet)
throws RemoteException;
}
</snippet>
I assumed extrapolating from the article above that I could have a
return type of File[] to return a collection of attached files.
The WSDL generated from this interface is all exactly as I'd expect it
to be - except in the wsdl:output element created within the
wsdl:operation element for my function call within the wsdl:binding
section of the WSDL.
Unfortunately, all I get is:
<snippet>
<wsdl:output name="getImagesResponse">
<wsdlsoap:body namespace="urn:RepositoryAccessService" use="encoded"/>
</wsdl:output>
</snippet>
According to the article, it should look something like this:
<snippet>
<wsdl:output name="getImagesResponse">
<mime:multipartRelated>
<mime:part name="part1">
<wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:RepositoryAccessService" use="encoded"/>
</mime:part>
<mime:part name="part2">
<mime:content part="output"
type="application/octetstream"/>
</mime:part>
</mime:multipartRelated>
</wsdl:output>
</snippet>
with:
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
included in the wsdl:definitions element at the top of the WSDL.
Basically, it's a multipart MIME message, where the first part is the
body of the SOAP response message, the the additional part(s) are the
attached binary files.
If I add in the mime:multipartRelated as given above into the
wsdl:output element, then try to run WSDL2Java, I get the following
error:
java org.apache.axis.wsdl.WSDL2Java --output "gen" --deployScope
"Application" --server-side --skeletonDeploy --verbose
RepositoryAcess.wsdl
java.lang.NullPointerException
at
org.apache.axis.wsdl.symbolTable.SymbolTable.addMIMETypes(SymbolTable.ja
va:2084)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.fillInBindingInfo(SymbolTab
le.java:1860)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings(SymbolTabl
e.java:1795)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
577)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:421)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
408)
at
org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
393)
at
org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:245)
at java.lang.Thread.run(Thread.java:552)
I peaked into the source for
org.apache.axis.wsdl.symbolTable.SymbolTable. At line 2084 where it's
hitting a NullPointerException, it is in the function addMIMETypes as
indicated above. Here's a snippet from that function:
<snippet>
/**
* Add the parts that are really MIME types as MIME types.
* A side effect is to return the body Type of the given
* MIMEMultipartRelated object.
*/
private Use addMIMETypes(BindingEntry bEntry, MIMEMultipartRelated
mpr,
Operation op) throws IOException {
Use bodyType = Use.ENCODED;
List parts = mpr.getMIMEParts();
Iterator i = parts.iterator();
while (i.hasNext()) {
MIMEPart part = (MIMEPart) i.next();
List elems = part.getExtensibilityElements();
Iterator j = elems.iterator();
while (j.hasNext()) {
Object obj = j.next();
if (obj instanceof MIMEContent) {
MIMEContent content = (MIMEContent) obj;
TypeEntry typeEntry = findPart(op,
content.getPart());
line:2084-->String dims = typeEntry.getDimensions();
if(dims.length() <=0 && typeEntry.getRefType() !=
null) {
Node node = typeEntry.getRefType().getNode();
if(getInnerCollectionComponentQName(node)!=null)
dims += "[]";
}
String type = content.getType();
if(type == null || type.length() == 0)
type = "text/plain";
bEntry.setMIMEInfo(op.getName(), content.getPart(),
type, dims);
</snippet>
As best I figure from this code, the typeEntry object is null, probably
because content.getPart() returns null or an invalid value.
I'm pretty certain I've got the wsdl:output MIME syntax in the WSDL
very close. The part I'm pretty certain is wrong is the line:
<mime:content part="output" type="application/octetstream"/>
I think the 'part="output" is the offending piece. The article I'm
using as my example describes how to create a WSDL for a function that
accepts an attachment as an input parameter, not one that returns an
attachment. I'm also trying to attach several files, not just a single
file. It seems I ought to have to specify I'm returning an array of
attachments somewhere in the mime:content element.
I've been to the World-Wide Web consortium site to look over the WSDL
v1.2 specification. There's very little info contained in the section
on MIME multi-part messages:
http://www.w3.org/TR/2003/WD-wsdl12-bindings-20030611/#_mime
There's really nothing here that goes much beyond the original article
I site above.
Can anyone suggest how to get this working?
Many thanks ahead of time for any assistance you can offer.
Cheers,
Bill Bug
Bill Bug
Senior Analyst/Ontological Engineer
Laboratory for Bioimaging & Anatomical Informatics
Department of Neurobiology & Anatomy
Drexel University College of Medicine
2900 Queen Lane
Philadelphia, PA 19129
215 991 8430 (ph)
Re: WSDL2Java - can't use mime:multipartRelated in wsdl:output element
Posted by Nicholas Remy <nr...@caci.com>.
Bill,
First, thanks for the great article link! I'm just starting on a project
that forces me to dig a little deeper into WS than I've had to previously.
Until now, I've gotten away with some *very* simple JAX-RPC code...but
new requirements have me exploring (while learning at the same time!) SOAP
w/ Attachments--which I've never done before! This article gives me hope!
Second, if you receive any resolution off-line, please post it to the
group. I, for one, will be watching this thread w/ interest!
Thanks.
Nick
P.S. If anyone has any *good* examples of SAAJ, for a relatively naive WS
developer (me), please forward a link!
ndr
William Bug <wb...@drexel.edu>
04/02/2004 10:14 AM
Please respond to
axis-user@ws.apache.org
To
axis-user@ws.apache.org
cc
Subject
Re: WSDL2Java - can't use mime:multipartRelated in wsdl:output element
Many thanks for you feedback, Davanum.
Are you sure this is a bug? Since your on the Apache webservices team,
I'll take your word for it.
I was expecting I'm just doing something wrong, though if there's a
right way to do this, I can't find it documented anywhere.
Is there really no way to get Java2WSDL to add the
"mime:multipartRelated" element inserted in the "wsdl:output" of a
"wsdl:operation" within the "wsdl:binding" portion of the WSDL
document?
Cheers,
Bill
Re: WSDL2Java - can't use mime:multipartRelated in wsdl:output element
Posted by Davanum Srinivas <di...@yahoo.com>.
Supported Scenario is to return javax.activation.DataHandler[] instead of File[] even that has a
problem. http://nagoya.apache.org/jira/browse/AXIS-1138
-- dims
--- William Bug <wb...@drexel.edu> wrote:
> Many thanks for you feedback, Davanum.
>
> Are you sure this is a bug? Since your on the Apache webservices team,
> I'll take your word for it.
>
> I was expecting I'm just doing something wrong, though if there's a
> right way to do this, I can't find it documented anywhere.
>
> Is there really no way to get Java2WSDL to add the
> "mime:multipartRelated" element inserted in the "wsdl:output" of a
> "wsdl:operation" within the "wsdl:binding" portion of the WSDL
> document?
>
> Cheers,
> Bill
>
> On Apr 2, 2004, at 8:52 AM, Davanum Srinivas wrote:
>
> > Please log a bug - http://issues.apache.org/jira/
> >
> > --- William Bug <Wi...@drexel.edu> wrote:
> >> Hi All,
> >>
> >> I'm having trouble creating an appropriate WSDL file to create a
> >> service that returns a large set of binary attachments.
> >>
> >> I've been trying to combine what I could pull from the documentation
> >> on
> >> WSDL2Java with the info in the very useful article:
> >>
> >> Web services programming tips and tricks: SOAP attachments with
> >> JAX-RPC
> >> http://www-106.ibm.com/developerworks/webservices/library/ws-tip-
> >> soapjax.html
> >>
> >> So far, I've not been successful.
> >>
> >> I've got an original implementation in SAAJ that works, but the code
> >> is
> >> much more complicated than it would be had I used JAX-RPC attachments
> >> as described in the article listed above.
> >>
> >> I created a very simple Interface that I ran through Java2WSDL to
> >> create my WSDL file.
> >>
> >> The Interface is as follows:
> >>
> >> <snippet>
> >> import java.io.File;
> >> import java.rmi.Remote;
> >> import java.rmi.RemoteException;
> >>
> >> /**
> >> *
> >> * @author billbug
> >> */
> >> public interface IRepositoryAccess extends Remote {
> >> public File[] getImages(Boolean returnZip, String imageSet)
> >> throws RemoteException;
> >> }
> >> </snippet>
> >>
> >> I assumed extrapolating from the article above that I could have a
> >> return type of File[] to return a collection of attached files.
> >>
> >> The WSDL generated from this interface is all exactly as I'd expect it
> >> to be - except in the wsdl:output element created within the
> >> wsdl:operation element for my function call within the wsdl:binding
> >> section of the WSDL.
> >> Unfortunately, all I get is:
> >>
> >> <snippet>
> >> <wsdl:output name="getImagesResponse">
> >> <wsdlsoap:body namespace="urn:RepositoryAccessService"
> >> use="encoded"/>
> >> </wsdl:output>
> >> </snippet>
> >>
> >> According to the article, it should look something like this:
> >>
> >> <snippet>
> >> <wsdl:output name="getImagesResponse">
> >> <mime:multipartRelated>
> >> <mime:part name="part1">
> >> <wsdlsoap:body
> >> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> >> namespace="urn:RepositoryAccessService" use="encoded"/>
> >> </mime:part>
> >> <mime:part name="part2">
> >> <mime:content part="output"
> >> type="application/octetstream"/>
> >> </mime:part>
> >> </mime:multipartRelated>
> >> </wsdl:output>
> >> </snippet>
> >>
> >> with:
> >> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
> >> included in the wsdl:definitions element at the top of the WSDL.
> >>
> >> Basically, it's a multipart MIME message, where the first part is the
> >> body of the SOAP response message, the the additional part(s) are the
> >> attached binary files.
> >>
> >> If I add in the mime:multipartRelated as given above into the
> >> wsdl:output element, then try to run WSDL2Java, I get the following
> >> error:
> >>
> >> java org.apache.axis.wsdl.WSDL2Java --output "gen" --deployScope
> >> "Application" --server-side --skeletonDeploy --verbose
> >> RepositoryAcess.wsdl
> >> java.lang.NullPointerException
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.addMIMETypes(SymbolTable.
> >> ja
> >> va:2084)
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.fillInBindingInfo(SymbolT
> >> ab
> >> le.java:1860)
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings(SymbolTa
> >> bl
> >> e.java:1795)
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java
> >> :
> >> 577)
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:421)
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java
> >> :
> >> 408)
> >> at
> >> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java
> >> :
> >> 393)
> >> at
> >> org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:245)
> >> at java.lang.Thread.run(Thread.java:552)
> >>
> >> I peaked into the source for
> >> org.apache.axis.wsdl.symbolTable.SymbolTable. At line 2084 where it's
> >> hitting a NullPointerException, it is in the function addMIMETypes as
> >> indicated above. Here's a snippet from that function:
> >>
> >> <snippet>
> >> /**
> >> * Add the parts that are really MIME types as MIME types.
> >> * A side effect is to return the body Type of the given
> >> * MIMEMultipartRelated object.
> >> */
> >> private Use addMIMETypes(BindingEntry bEntry,
> >> MIMEMultipartRelated
> >> mpr,
> >> Operation op) throws IOException {
> >> Use bodyType = Use.ENCODED;
> >> List parts = mpr.getMIMEParts();
> >> Iterator i = parts.iterator();
> >> while (i.hasNext()) {
> >> MIMEPart part = (MIMEPart) i.next();
> >> List elems = part.getExtensibilityElements();
> >> Iterator j = elems.iterator();
> >> while (j.hasNext()) {
> >> Object obj = j.next();
> >> if (obj instanceof MIMEContent) {
> >> MIMEContent content = (MIMEContent) obj;
> >> TypeEntry typeEntry = findPart(op,
> >> content.getPart());
> >> line:2084-->String dims = typeEntry.getDimensions();
> >> if(dims.length() <=0 && typeEntry.getRefType() !=
> >> null) {
> >> Node node = typeEntry.getRefType().getNode();
> >>
> >> if(getInnerCollectionComponentQName(node)!=null)
> >> dims += "[]";
> >> }
> >> String type = content.getType();
> >> if(type == null || type.length() == 0)
> >> type = "text/plain";
> >> bEntry.setMIMEInfo(op.getName(),
> >> content.getPart(),
> >> type, dims);
> >> </snippet>
> >>
> >> As best I figure from this code, the typeEntry object is null,
> >> probably
> >> because content.getPart() returns null or an invalid value.
> >>
> >> I'm pretty certain I've got the wsdl:output MIME syntax in the WSDL
> >> very close. The part I'm pretty certain is wrong is the line:
> >>
> >> <mime:content part="output" type="application/octetstream"/>
> >>
> >> I think the 'part="output" is the offending piece. The article I'm
> >> using as my example describes how to create a WSDL for a function that
> >> accepts an attachment as an input parameter, not one that returns an
> >> attachment. I'm also trying to attach several files, not just a
> >> single
> >> file. It seems I ought to have to specify I'm returning an array of
>
=== message truncated ===
=====
Davanum Srinivas - http://webservices.apache.org/~dims/
Re: WSDL2Java - can't use mime:multipartRelated in wsdl:output element
Posted by William Bug <wb...@drexel.edu>.
Many thanks for you feedback, Davanum.
Are you sure this is a bug? Since your on the Apache webservices team,
I'll take your word for it.
I was expecting I'm just doing something wrong, though if there's a
right way to do this, I can't find it documented anywhere.
Is there really no way to get Java2WSDL to add the
"mime:multipartRelated" element inserted in the "wsdl:output" of a
"wsdl:operation" within the "wsdl:binding" portion of the WSDL
document?
Cheers,
Bill
On Apr 2, 2004, at 8:52 AM, Davanum Srinivas wrote:
> Please log a bug - http://issues.apache.org/jira/
>
> --- William Bug <Wi...@drexel.edu> wrote:
>> Hi All,
>>
>> I'm having trouble creating an appropriate WSDL file to create a
>> service that returns a large set of binary attachments.
>>
>> I've been trying to combine what I could pull from the documentation
>> on
>> WSDL2Java with the info in the very useful article:
>>
>> Web services programming tips and tricks: SOAP attachments with
>> JAX-RPC
>> http://www-106.ibm.com/developerworks/webservices/library/ws-tip-
>> soapjax.html
>>
>> So far, I've not been successful.
>>
>> I've got an original implementation in SAAJ that works, but the code
>> is
>> much more complicated than it would be had I used JAX-RPC attachments
>> as described in the article listed above.
>>
>> I created a very simple Interface that I ran through Java2WSDL to
>> create my WSDL file.
>>
>> The Interface is as follows:
>>
>> <snippet>
>> import java.io.File;
>> import java.rmi.Remote;
>> import java.rmi.RemoteException;
>>
>> /**
>> *
>> * @author billbug
>> */
>> public interface IRepositoryAccess extends Remote {
>> public File[] getImages(Boolean returnZip, String imageSet)
>> throws RemoteException;
>> }
>> </snippet>
>>
>> I assumed extrapolating from the article above that I could have a
>> return type of File[] to return a collection of attached files.
>>
>> The WSDL generated from this interface is all exactly as I'd expect it
>> to be - except in the wsdl:output element created within the
>> wsdl:operation element for my function call within the wsdl:binding
>> section of the WSDL.
>> Unfortunately, all I get is:
>>
>> <snippet>
>> <wsdl:output name="getImagesResponse">
>> <wsdlsoap:body namespace="urn:RepositoryAccessService"
>> use="encoded"/>
>> </wsdl:output>
>> </snippet>
>>
>> According to the article, it should look something like this:
>>
>> <snippet>
>> <wsdl:output name="getImagesResponse">
>> <mime:multipartRelated>
>> <mime:part name="part1">
>> <wsdlsoap:body
>> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
>> namespace="urn:RepositoryAccessService" use="encoded"/>
>> </mime:part>
>> <mime:part name="part2">
>> <mime:content part="output"
>> type="application/octetstream"/>
>> </mime:part>
>> </mime:multipartRelated>
>> </wsdl:output>
>> </snippet>
>>
>> with:
>> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
>> included in the wsdl:definitions element at the top of the WSDL.
>>
>> Basically, it's a multipart MIME message, where the first part is the
>> body of the SOAP response message, the the additional part(s) are the
>> attached binary files.
>>
>> If I add in the mime:multipartRelated as given above into the
>> wsdl:output element, then try to run WSDL2Java, I get the following
>> error:
>>
>> java org.apache.axis.wsdl.WSDL2Java --output "gen" --deployScope
>> "Application" --server-side --skeletonDeploy --verbose
>> RepositoryAcess.wsdl
>> java.lang.NullPointerException
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.addMIMETypes(SymbolTable.
>> ja
>> va:2084)
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.fillInBindingInfo(SymbolT
>> ab
>> le.java:1860)
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings(SymbolTa
>> bl
>> e.java:1795)
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java
>> :
>> 577)
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:421)
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java
>> :
>> 408)
>> at
>> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java
>> :
>> 393)
>> at
>> org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:245)
>> at java.lang.Thread.run(Thread.java:552)
>>
>> I peaked into the source for
>> org.apache.axis.wsdl.symbolTable.SymbolTable. At line 2084 where it's
>> hitting a NullPointerException, it is in the function addMIMETypes as
>> indicated above. Here's a snippet from that function:
>>
>> <snippet>
>> /**
>> * Add the parts that are really MIME types as MIME types.
>> * A side effect is to return the body Type of the given
>> * MIMEMultipartRelated object.
>> */
>> private Use addMIMETypes(BindingEntry bEntry,
>> MIMEMultipartRelated
>> mpr,
>> Operation op) throws IOException {
>> Use bodyType = Use.ENCODED;
>> List parts = mpr.getMIMEParts();
>> Iterator i = parts.iterator();
>> while (i.hasNext()) {
>> MIMEPart part = (MIMEPart) i.next();
>> List elems = part.getExtensibilityElements();
>> Iterator j = elems.iterator();
>> while (j.hasNext()) {
>> Object obj = j.next();
>> if (obj instanceof MIMEContent) {
>> MIMEContent content = (MIMEContent) obj;
>> TypeEntry typeEntry = findPart(op,
>> content.getPart());
>> line:2084-->String dims = typeEntry.getDimensions();
>> if(dims.length() <=0 && typeEntry.getRefType() !=
>> null) {
>> Node node = typeEntry.getRefType().getNode();
>>
>> if(getInnerCollectionComponentQName(node)!=null)
>> dims += "[]";
>> }
>> String type = content.getType();
>> if(type == null || type.length() == 0)
>> type = "text/plain";
>> bEntry.setMIMEInfo(op.getName(),
>> content.getPart(),
>> type, dims);
>> </snippet>
>>
>> As best I figure from this code, the typeEntry object is null,
>> probably
>> because content.getPart() returns null or an invalid value.
>>
>> I'm pretty certain I've got the wsdl:output MIME syntax in the WSDL
>> very close. The part I'm pretty certain is wrong is the line:
>>
>> <mime:content part="output" type="application/octetstream"/>
>>
>> I think the 'part="output" is the offending piece. The article I'm
>> using as my example describes how to create a WSDL for a function that
>> accepts an attachment as an input parameter, not one that returns an
>> attachment. I'm also trying to attach several files, not just a
>> single
>> file. It seems I ought to have to specify I'm returning an array of
>> attachments somewhere in the mime:content element.
>>
>> I've been to the World-Wide Web consortium site to look over the WSDL
>> v1.2 specification. There's very little info contained in the section
>> on MIME multi-part messages:
>> http://www.w3.org/TR/2003/WD-wsdl12-bindings-20030611/#_mime
>> There's really nothing here that goes much beyond the original article
>> I site above.
>>
>> Can anyone suggest how to get this working?
>>
>> Many thanks ahead of time for any assistance you can offer.
>>
>> Cheers,
>> Bill Bug
>>
>> Bill Bug
>> Senior Analyst/Ontological Engineer
>>
>> Laboratory for Bioimaging & Anatomical Informatics
>> Department of Neurobiology & Anatomy
>> Drexel University College of Medicine
>> 2900 Queen Lane
>> Philadelphia, PA 19129
>> 215 991 8430 (ph)
>>
>
>
> =====
> Davanum Srinivas - http://webservices.apache.org/~dims/
>
>
Bill Bug
Senior Analyst/Ontological Engineer
Laboratory for Bioimaging & Anatomical Informatics
Department of Neurobiology & Anatomy
Drexel University College of Medicine
2900 Queen Lane
Philadelphia, PA 19129
215 991 8430 (ph)
RE: Emply xmlns attribute
Posted by Robert Lowe <rm...@rmlowe.com>.
Nick,
The following fragments:
<i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
<item xmlns="">12345</item>
</i:getImage>
<i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
<i:item>12345</item>
</i:getImage>
are *not* equivalent in general. Which one is correct depends on your
schema. Specifically, the first is correct if the schema specifies
elementFormDefault="unqualified", or if the schema doesn't include the
elementFormDefault attribute; the second is correct if the schema specifies
elementFormDefault="qualified".
Best regards,
Robert Lowe
http://RMLowe.com/
-----Original Message-----
From: Nicholas Remy [mailto:nremy@caci.com]
Sent: Friday, April 02, 2004 11:16 PM
To: axis-user@ws.apache.org
Subject: Emply xmlns attribute
Group,
The following code snippet:
<snip>
SOAPFactory sf = SOAPFactory.newInstance();
Name bodyName = sf.createName("getImage", "i",
"http://www.mycompany.com");
SOAPBodyElement sbe = soapBody.addBodyElement(bodyName);
Name usrName = sf.createName("user");
SOAPElement usr = sbe.addAttribute(usrName, "keymaster");
Name pwdName = sf.createName("pwd");
SOAPElement pwd = sbe.addAttribute(pwdName, "gatekeeper");
Name latName = sf.createName("item");
SOAPElement lat = sbe.addChildElement(latName);
lat.addTextNode("12345");
</snip>
...produces the following SOAP:
<snip>
<i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
<item xmlns="">12345</item>
</i:getImage>
</snip>
The tutorials and examples I used to build the code gave no indication that
the xmlns attribute would be present--let alone blank. Is there a way to
avoid the empty/null xmlns (xmlns="")?
Thank you!
Nicholas (Nick) Remy
Emply xmlns attribute
Posted by Nicholas Remy <nr...@caci.com>.
Group,
The following code snippet:
<snip>
SOAPFactory sf = SOAPFactory.newInstance();
Name bodyName = sf.createName("getImage", "i",
"http://www.mycompany.com");
SOAPBodyElement sbe = soapBody.addBodyElement(bodyName);
Name usrName = sf.createName("user");
SOAPElement usr = sbe.addAttribute(usrName, "keymaster");
Name pwdName = sf.createName("pwd");
SOAPElement pwd = sbe.addAttribute(pwdName, "gatekeeper");
Name latName = sf.createName("item");
SOAPElement lat = sbe.addChildElement(latName);
lat.addTextNode("12345");
</snip>
...produces the following SOAP:
<snip>
<i:getImage user="keymaster" pwd="gatekeeper"
xmlns:i="http://www.mycompany.com">
<item xmlns="">12345</item>
</i:getImage>
</snip>
The tutorials and examples I used to build the code gave no indication
that the xmlns attribute would be present--let alone blank. Is there a
way to avoid the empty/null xmlns (xmlns="")?
Thank you!
Nicholas (Nick) Remy
Re: WSDL2Java - can't use mime:multipartRelated in wsdl:output element
Posted by Davanum Srinivas <di...@yahoo.com>.
Please log a bug - http://issues.apache.org/jira/
--- William Bug <Wi...@drexel.edu> wrote:
> Hi All,
>
> I'm having trouble creating an appropriate WSDL file to create a
> service that returns a large set of binary attachments.
>
> I've been trying to combine what I could pull from the documentation on
> WSDL2Java with the info in the very useful article:
>
> Web services programming tips and tricks: SOAP attachments with JAX-RPC
> http://www-106.ibm.com/developerworks/webservices/library/ws-tip-
> soapjax.html
>
> So far, I've not been successful.
>
> I've got an original implementation in SAAJ that works, but the code is
> much more complicated than it would be had I used JAX-RPC attachments
> as described in the article listed above.
>
> I created a very simple Interface that I ran through Java2WSDL to
> create my WSDL file.
>
> The Interface is as follows:
>
> <snippet>
> import java.io.File;
> import java.rmi.Remote;
> import java.rmi.RemoteException;
>
> /**
> *
> * @author billbug
> */
> public interface IRepositoryAccess extends Remote {
> public File[] getImages(Boolean returnZip, String imageSet)
> throws RemoteException;
> }
> </snippet>
>
> I assumed extrapolating from the article above that I could have a
> return type of File[] to return a collection of attached files.
>
> The WSDL generated from this interface is all exactly as I'd expect it
> to be - except in the wsdl:output element created within the
> wsdl:operation element for my function call within the wsdl:binding
> section of the WSDL.
> Unfortunately, all I get is:
>
> <snippet>
> <wsdl:output name="getImagesResponse">
> <wsdlsoap:body namespace="urn:RepositoryAccessService" use="encoded"/>
> </wsdl:output>
> </snippet>
>
> According to the article, it should look something like this:
>
> <snippet>
> <wsdl:output name="getImagesResponse">
> <mime:multipartRelated>
> <mime:part name="part1">
> <wsdlsoap:body
> encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
> namespace="urn:RepositoryAccessService" use="encoded"/>
> </mime:part>
> <mime:part name="part2">
> <mime:content part="output"
> type="application/octetstream"/>
> </mime:part>
> </mime:multipartRelated>
> </wsdl:output>
> </snippet>
>
> with:
> xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
> included in the wsdl:definitions element at the top of the WSDL.
>
> Basically, it's a multipart MIME message, where the first part is the
> body of the SOAP response message, the the additional part(s) are the
> attached binary files.
>
> If I add in the mime:multipartRelated as given above into the
> wsdl:output element, then try to run WSDL2Java, I get the following
> error:
>
> java org.apache.axis.wsdl.WSDL2Java --output "gen" --deployScope
> "Application" --server-side --skeletonDeploy --verbose
> RepositoryAcess.wsdl
> java.lang.NullPointerException
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.addMIMETypes(SymbolTable.ja
> va:2084)
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.fillInBindingInfo(SymbolTab
> le.java:1860)
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.populateBindings(SymbolTabl
> e.java:1795)
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
> 577)
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.add(SymbolTable.java:421)
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
> 408)
> at
> org.apache.axis.wsdl.symbolTable.SymbolTable.populate(SymbolTable.java:
> 393)
> at
> org.apache.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:245)
> at java.lang.Thread.run(Thread.java:552)
>
> I peaked into the source for
> org.apache.axis.wsdl.symbolTable.SymbolTable. At line 2084 where it's
> hitting a NullPointerException, it is in the function addMIMETypes as
> indicated above. Here's a snippet from that function:
>
> <snippet>
> /**
> * Add the parts that are really MIME types as MIME types.
> * A side effect is to return the body Type of the given
> * MIMEMultipartRelated object.
> */
> private Use addMIMETypes(BindingEntry bEntry, MIMEMultipartRelated
> mpr,
> Operation op) throws IOException {
> Use bodyType = Use.ENCODED;
> List parts = mpr.getMIMEParts();
> Iterator i = parts.iterator();
> while (i.hasNext()) {
> MIMEPart part = (MIMEPart) i.next();
> List elems = part.getExtensibilityElements();
> Iterator j = elems.iterator();
> while (j.hasNext()) {
> Object obj = j.next();
> if (obj instanceof MIMEContent) {
> MIMEContent content = (MIMEContent) obj;
> TypeEntry typeEntry = findPart(op,
> content.getPart());
> line:2084-->String dims = typeEntry.getDimensions();
> if(dims.length() <=0 && typeEntry.getRefType() !=
> null) {
> Node node = typeEntry.getRefType().getNode();
> if(getInnerCollectionComponentQName(node)!=null)
> dims += "[]";
> }
> String type = content.getType();
> if(type == null || type.length() == 0)
> type = "text/plain";
> bEntry.setMIMEInfo(op.getName(), content.getPart(),
> type, dims);
> </snippet>
>
> As best I figure from this code, the typeEntry object is null, probably
> because content.getPart() returns null or an invalid value.
>
> I'm pretty certain I've got the wsdl:output MIME syntax in the WSDL
> very close. The part I'm pretty certain is wrong is the line:
>
> <mime:content part="output" type="application/octetstream"/>
>
> I think the 'part="output" is the offending piece. The article I'm
> using as my example describes how to create a WSDL for a function that
> accepts an attachment as an input parameter, not one that returns an
> attachment. I'm also trying to attach several files, not just a single
> file. It seems I ought to have to specify I'm returning an array of
> attachments somewhere in the mime:content element.
>
> I've been to the World-Wide Web consortium site to look over the WSDL
> v1.2 specification. There's very little info contained in the section
> on MIME multi-part messages:
> http://www.w3.org/TR/2003/WD-wsdl12-bindings-20030611/#_mime
> There's really nothing here that goes much beyond the original article
> I site above.
>
> Can anyone suggest how to get this working?
>
> Many thanks ahead of time for any assistance you can offer.
>
> Cheers,
> Bill Bug
>
> Bill Bug
> Senior Analyst/Ontological Engineer
>
> Laboratory for Bioimaging & Anatomical Informatics
> Department of Neurobiology & Anatomy
> Drexel University College of Medicine
> 2900 Queen Lane
> Philadelphia, PA 19129
> 215 991 8430 (ph)
>
=====
Davanum Srinivas - http://webservices.apache.org/~dims/