First of all, here is my wsdl file:
--------------START OF WSDL-------------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://
www.w3.org/2001/XMLSchema" xmlns:http="http://schemas.xmlsoap.org/wsdl/
http/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xtml="http://
www.foobar.com/schemas/common" xmlns:cnf="urn:com.foo.bar"
targetNamespace="urn:com.foo.bar">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://
www.foobar.com/schemas/common">
<s:element name="TrxnID">
<s:simpleType>
<s:restriction base="s:string"/>
</s:simpleType>
</s:element>
<s:element name="src-sessionID">
<s:simpleType>
<s:restriction base="s:string"/>
</s:simpleType>
</s:element>
<s:element name="dst-sessionID">
<s:simpleType>
<s:restriction base="s:string"/>
</s:simpleType>
</s:element>
</s:schema>
<s:schema elementFormDefault="qualified"
targetNamespace="urn:com.foo.bar">
<s:simpleType name="tStatus">
<s:restriction base="s:string"/>
</s:simpleType>
<s:simpleType name="tPhoneNumber">
<s:restriction base="s:string"/>
</s:simpleType>
</s:schema>
</wsdl:types>
<wsdl:message name="RequestHeader">
<wsdl:part name="TrxnID" element="xtml:TrxnID"/>
<wsdl:part name="dst-sessionID" element="xtml:dst-sessionID"/>
</wsdl:message>
<wsdl:message name="ResponseHeader">
<wsdl:part name="TrxnID" element="xtml:TrxnID"/>
<wsdl:part name="src-sessionID" element="xtml:src-sessionID"/>
</wsdl:message>
<wsdl:message name="OutdialRequest">
<wsdl:part name="callingNumber" type="cnf:tPhoneNumber"/>
<wsdl:part name="calledNumber" type="cnf:tPhoneNumber"/>
<wsdl:part name="passCode" type="s:string"/>
</wsdl:message>
<wsdl:message name="OutdialResponse">
<wsdl:part name="status" type="cnf:tStatus"/>
</wsdl:message>
<wsdl:portType name="ConferencePort">
<wsdl:operation name="OutdialOperation">
<wsdl:input message="cnf:OutdialRequest"/>
<wsdl:output message="cnf:OutdialResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ConferenceSOAPBinding" type="cnf:ConferencePort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/
http"/>
<wsdl:operation name="OutdialOperation">
<soap:operation soapAction="urn:com.foo.bar"/>
<wsdl:input>
<soap:body use="literal" namespace="urn:com.foo.bar"
wsdl:required="true"/>
<soap:header message="cnf:RequestHeader" part="TrxnID"
use="literal"/>
<soap:header message="cnf:RequestHeader" part="dst-sessionID"
use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal" namespace="urn:com.foo.bar"
wsdl:required="true"/>
<soap:header message="cnf:ResponseHeader" part="TrxnID"
use="literal"/>
<soap:header message="cnf:ResponseHeader" part="src-sessionID"
use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ConferenceService">
<wsdl:port name="Conferencing" binding="cnf:ConferenceSOAPBinding"/>
</wsdl:service>
</wsdl:definitions>
--------------END OF WSDL-------------------
and here is what the generated SOAP message looks like:
-------------START OF GENERATED SOAP REQUEST------------
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<TrxnID xmlns="http://www.foobar.com/schemas/common">1234</TrxnID>
</soap:Header>
<soap:Body>
<OutdialOperation xmlns="urn:com.foo.bar">
<callingNumber xmlns="">781</callingNumber>
<calledNumber xmlns="">784</calledNumber>
<passCode xmlns="">1234</passCode>
</OutdialOperation>
</soap:Body>
</soap:Envelope>
-------------END OF GENERATED SOAP REQUEST--------------
The problem is that I wanted the parameters in my message, like
'callingNumber', to be associated with the namespace
"urn:com.foo.bar", but as you can see they are associated with a blank
namespace.
Any idea what I am doing wrong? It must be a problem with my wsdl,
right? Can anyone suggest how I modify that wsdl to correctly
indicate that the parameters in my request message above are
associated with that namespace?
<callingNumber xmlns="">
I'm not sure of the answer to this, as I use document/literal, not
rpc. However, consider using elements for your parts instead of types.
Elements carry a namespace, but I'm not so sure about types.
John
c:\temp>wsdl /language:CS conference5.wsdl
Microsoft (R) Web Services Description Language Utility
[Microsoft (R) .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation. All rights reserved.
Warning: This web reference does not conform to WS-I Basic Profile
v1.1.
R2203: An rpc-literal binding in a DESCRIPTION MUST refer, in its
soapbind:body
element(s), only to wsdl:part element(s) that have been defined using
the type attribute.
- Part 'callingNumber' of message 'OutdialRequest' from service
description with targetNamespace='urn:com.pactolus.conferencing'.
- Part 'calledNumber' of message 'OutdialRequest' from service
description with targetNamespace='urn:com.pactolus.conferencing'.
- Part 'passCode' of message 'OutdialRequest' from service
description with targetNamespace='urn:com.pactolus.conferencing'.
For more details on the WS-I Basic Profile v1.1, see the specification
at http://www.ws-i.org/Profiles/BasicProfile-1.1.html.
Warning: one or more operations were skipped.
Warnings were encountered. Review generated source comments for more
details.
Writing file 'c:\temp\ConferenceService.cs'.
Stepping through wouldn't show you _why_ it's adding a namespace, it would
only show you _when_ it's adding the namespace.
The short and unsatisfying answer is that the namespace is being included
because .NET thinks it's necessary.
John
> The short and unsatisfying answer is that the namespace is being included
> because .NET thinks it's necessary.
Well, that is a good point, actually. Something in my wsdl must be
causing it to think this is necessary. And so, I then ask myself:
what is the intent of blank namespace? And I think a blank namespace
causes the active namespace to revert to the default namespace, is
that correct? If so, then .NET believes that the elements in my
message belong to the default namespace. This at least does give me
some avenues for investigating my wsdl...
A postscript on this. I was never able to figure out why this was
occurring, but I changed my wsdl document to use style=document
instead of style=rpc and now I get the expected behavior. Since the
web service is able to handle the SOAP generated with document style,
that is good enough for me for now.