I've generated a service stub from a wsdl, filled in a basic service body,
packaged it up as a war and deployed to tomcat.
I've been using this for a few services, and it's always seemed to work, but
today, I was trying to build a new client starting from the original wsdl, and
it failed quite miserably. Closer investigation shows that the dynamic wsdl is
rather different from the wsdl that I started with.
I know there has to be a bit of jiggerypokery to work with the "unbounded"
elements, but even the regular elements have got new namespaces!
From the original wsdl... (snipped parts not relevant)
<wsdl:definitions name="Mailer"
targetNamespace="http://www.industria.com/services/troubleticketing/mailer"
xmlns:tns="http://www.industria.com/services/troubleticketing/mailer">
<wsdl:types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.industria.com/services/troubleticketing/mailer">
<xsd:complexType name="MailAnyStringRequest">
<xsd:sequence>
<xsd:element maxOccurs="unbounded"
name="EmailAddresses" type="xsd:string" />
<xsd:element name="Subject"
type="xsd:string" />
<xsd:element name="Body"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
.......
Schema says that this means the following is a valid request message
<tns:MailAnyStringRequest
xmlns:tns="http://www.industria.com/services/troubleticketing/mailer"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EmailAddresses>EmailAddresses</EmailAddresses>
<EmailAddresses>EmailAddresses</EmailAddresses>
<EmailAddresses>EmailAddresses</EmailAddresses>
<EmailAddresses>EmailAddresses</EmailAddresses>
<EmailAddresses>EmailAddresses</EmailAddresses>
<Subject>Subject</Subject>
<Body>Body</Body>
</tns:MailAnyStringRequest>
Now, I know that that EmailAddresses will get fiddled with, but I still expect
the subject, body, and email addresses to stay in the same namespace
Here's the snippet from what xfire generates at runtime....
<wsdl:definitions xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:tns="http://www.industria.com/services/troubleticketing/mailer"
xmlns:ns1="http://mailer.troubleticketing.services.industria.com"
targetNamespace="http://www.industria.com/services/troubleticketing/mailer"|
<wsdl:types>
<xsd:schema attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://mailer.troubleticketing.services.industria.com">
<xsd:complexType name="MailAnyStringRequest">
<xsd:sequence>
<xsd:element minOccurs="0" name="body"
nillable="true" type="xsd:string" />
<xsd:element minOccurs="0"
name="emailAddresses" nillable="true"
type="tns:ArrayOfString" />
<xsd:element minOccurs="0"
name="subject" nillable="true" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<xsd:schema attributeFormDefault="qualified"
elementFormDefault="qualified"
targetNamespace="http://www.industria.com/services/troubleticketing/mailer">
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element minOccurs="0"
maxOccurs="unbounded" name="string" nillable="true"
type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="MailAnyStringRequest"
type="ns1:MailAnyStringRequest" />
</xsd:schema>
</wsdl:types>
Note that ns1 and the target namespace of the first inline schema are
"http://mailer.troubleticketing.services.industria.com"
This namespace is not mentioned anywhere in any of my source, config files, or
any of the wsdls anywhere. The only acceptable client request message now
looks like this...
<MailAnyStringRequest
xmlns="http://www.industria.com/services/troubleticketing/mailer">
<body
xmlns="http://mailer.troubleticketing.services.industria.com">body</body>
<emailAddresses
xmlns="http://mailer.troubleticketing.services.industria.com">
<string
xmlns="http://www.industria.com/services/troubleticketing/mailer">myemailaddress</string>
</emailAddresses>
<subject
xmlns="http://mailer.troubleticketing.services.industria.com">subject</subject>
</MailAnyStringRequest>
I know that the emailAddresses element is going to get all screwy, but the body
and subject now have the new autogenerated namespace.
Why is this? And is there anyway to actually use the same wsdl to generate both
the server and client interfaces? It seems to defeat the purpose a bit if
after generating a service I have to go and use a new wsdl for the client.
Sorry for the long thread with lots of xml snips, but there's no other way to
really illustrate this.
Cheers,
Karl P