Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2004

Tip: Looking for answers? Try searching our database.

Mapping complex elements to url-encoded strings

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
yuri - 07 Nov 2004 09:54 GMT
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"&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
Dan Rogers - 04 Dec 2004 00:54 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.