Hi Yuri,
Unless you manually do this encoding (say for invoking via the HTTP Get
binding), then no, you don't need to UrlEncode this data. If you did, it
would fail serializaiton, since the WSDL you showed expects an Xml element
to show up, and this is not the same thing as a UrlEncoded string.
One thing to consider (other than defining your methods as loosley coupled
by making the parms XmlNode's) is to create classes that represent this
data, and use those classes as your parm types. You can hand code these,
and attribute them properly with XmlRootAttribute, XmlElementAttribute and
if you need to use XML attributes on the wire, XmlAttributeAttribute. The
reason you might need to attribute your data classes is to get the correct
XML namespace association with the class metadata.
An easy way to do this as well is to generate the code for your data
classes with either Xsd.EXE or XsdObjectGen.exe. These tools automatically
put in the proper Xml*Attribute logic.
I hope this helps
Dan Rogers
Microsoft Corporation
--------------------
From: "yuri" <yuri67@cablespeed.com>
Subject: Mapping complex elements to url-encoded strings
Date: Sun, 7 Nov 2004 01:54:18 -0800
Lines: 220
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0008_01C4C46C.B161DF70"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <O3dCI$KxEHA.4028@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: c66-235-38-219.sea2.cablespeed.com 66.235.38.219
Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP15
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7284
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices
Hello,
Is it possible to create a binding that would map an input message with a
part defined as a complex-type element to a url-encoded string?
For example, wsdl file defines a message as
<wsdl:message name="MyRequestMsg">
<wsdl:part name="myData" element="req:myData"/>
</wsdl:message>
The schema defines req:myData element as below:
<xs:schema
targetNamespace="http://www.mysample.org/requests/"
elementFormDefault="qualified"
xmlns:rec="http://www.mysample.org/requests/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
<xs:complexType name="MyData">
<xs:sequence>
<xs:element name="counter" type="xs:integer"/>
<xs:element name="message" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="myData" type="rec:MyData"/>
</xs:schema>
I would like to bind this message to a service that accepts traditional
url-encoded HTTP GET requests:
<wsdl:binding name="MyService" type="MyServiceInterface">
<http:binding verb="GET"/>
<wsdl:operation name="MyOperation">
<http:operation location="MyOperation.aspx"/>
<wsdl:input>
<http:urlEncoded/>
</wsdl:input>
<wsdl:output>
<mime:mimeXml/>
</wsdl:output>
</wsdl:operation>
Specifically, if I have an element
<rec:myData>
<rec:counter>22</rec:counter>
<rec:message>Hello World</rec:message>
</rec:myData>
then I would like to flatten it so it is mapped to a url-encoded string as
below:
../MyOperation.aspx?counter=22&message=Hello+World
So far I was not able to do this. Moreover, I found that wsdl.exe from
.NET framework v 1.1.4322.573 ignores element attribute in a message part.
The only way I was able to pass multiple parameters to the generated stub
is by defining a multi-part message:
<wsdl:message name="MyRequestMsg">
<wsdl:part name="time" element="req:whatever-willBeIgnoredAnyway"/>
<wsdl:part name="message" element="req:whatever-willBeIgnoredAnyway"/>
</wsdl:message>
Am I doing something wrong or is it just wsdl 1.1 that does not allow
binding the same port types to the services with different protocols?
Thanks,
Yuri