Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Converting Document-Literal to Rpc-Encoded

356 views
Skip to first unread message

Indra

unread,
Mar 12, 2004, 8:34:45 PM3/12/04
to
Does anyone have any .NET code snippets or articles that demonstrate
how to take a doc-literal style XML and translate it to rpc-encoded. I
need this on the client side for calling web services in a generic
manner.

I am given document style XML. However, the web service I call is
rpc-encoded style. I am struggling with how to accomplish this without
dealing with all the intricacies of parsing the type information in
the XML schemas and dealing with Array types etc. All the sample code
on the internet is centered around either using the .NET generted
proxies or using classes that serialize an object. I am stuck because
I am working with raw XML and not an object.

Any help would be greatly appreciated.

Thanks in advance,
Indra

Steven Cheng[MSFT]

unread,
Mar 13, 2004, 3:52:42 AM3/13/04
to
Hi Indra,

Thanks for posting in the community!
From your description, you're going to consume a webservice which is
rpc-encoded style. However, the raw xml of the soap message you got(used to
post from client) is document-literal style. So you're wondering how to
convert it, yes?
If there is anything I misunderstood, please feel free to let me know.

As for this questions, I'd like to confirm some certain things:
1. Is the webservice built via .net (asp.net webservice) or other?

2. Are you able to generate a client proxy class to call the certain
webservice by some tools such as wsdl.exe or in VS.NET using the "Add
Reference" function?

Generally, I've not found any buildin classes or components in DOTNET which
provides the fuctions of converting between the two style soap message,
because the proxy will automatically generate it via the wsdl description.
As I mentioned in the above #2, if you're able to generate a client proxy
class to all the webservice, then you can try using some net monitor tools
to capture the raw xml datas transfer the serverside. Thus, you can get it
without doing any converting. As for the tools ,you may use the tool in the
soap tookit which is still avaliable via the following web link:

http://msdn.microsoft.com/webservices/building/soaptk/default.aspx
or any other soap test utility:
http://www.stargeek.com/item/26086.html

In addition, if you do want to manually transform between the two styles of
soapmessage, below is a tech article discussing on manually transform
RPC-ENCODED to DOCUMENT-LITERAL. Though not what you want , but I think
maybe it can give some clues:

#Rpc and document SOAP from one .NET web service(transforms an rpc/encoded
message into a doc/literal one)
http://radio.weblogs.com/0105476/stories/2002/04/12/rpcAndDocumentSoapFromOn
enetWebService.html

and also some related reference in MSDN:
#RPC/Literal and Freedom of Choice
http://msdn.microsoft.com/library/en-us/dnwebsrv/html/rpc_literal.asp?frame=
true

#Customizing SOAP Messages
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconCustomizingSOAPInA
SPNETWebServicesWebServiceClients.asp?frame=true#cpconcustomizingsoapinaspne
twebserviceswebserviceclientsanchor1

Hope them also help.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Indra

unread,
Mar 13, 2004, 10:27:04 PM3/13/04
to
Steven --

Thank you for your response!

What I want to do is the opposite of what is described in the articles
you pointed to. I will get data in an XML doc that is similar to
doc-literal style from the layer above me. However, the web service I
need to call may be rpc-encoded. So, I need to convert a doc-literal
message to rpc-encoded to make the web service call. The web services
being called may be .NET generated or not. Also, we don't want to use
.NET generated proxy's and want to generate the SOAP message itself.

For this, I would need to add type information to the XML and handle
arrays and structs for the rpc message. I am wondering if there are
any classes in .NET that I can call, provide a WSDL message, and ask
for the XML representation of this message with the type information
and the array and struct constructs handled? I could then add the data
to this doc.

Alternatively, are there any classes to which I can give the schemas
and the document style doc to and get an rpc-style doc returned? Or,
are there any classes that can make the parsing of the XML schemas in
the WSDL easier so I don't have to worry about the many different ways
in which element/types can be defined in a WSDL?

Thanks in advance,
Indra

Indra

unread,
Mar 13, 2004, 10:27:51 PM3/13/04
to

Steven Cheng[MSFT]

unread,
Mar 16, 2004, 7:09:45 AM3/16/04
to
Hi Indra,

Thanks for your response. As for any buildin .Net classes for transforming
or parsing certain XML schemas, currently I haven't found any. And I'm now
consulting some other experts on such speciality and I'll update you as
soon as I've got any further infos.
Also, if you just want to call a certain webservice(not for common
transformation). I think you can consider the means that use VS.NET or
wsdl.exe to generate a proxy and call the webservice ,then use some certain
soap utilitiy to capture the raw xml soap message.

Steven Cheng[MSFT]

unread,
Mar 18, 2004, 7:33:32 AM3/18/04
to
Hi Indra,

After some further cosulting, it seems that there haven't any buildin
classes in .NET framework which are capable of converting raw xml
soapmessage between Document-Literal and Rpc-Encoded styles. One workaround
is as I've mentioned that use the wsdl.exe to generate a client proxy(which
can use Attributes to spedify whether the client proxy use Document-Literal
sytle or Rpc-Encoded style). Then use t he proxy call the webservice and
use tools to capture the raw xml message. And here is detailed description
from consultant:

----------------------------------------------------------------------------
--------------------------
Both document style and rpc style are supported in .NET Framework while
document is the default style in asp.net web services. So, you could use
wsdl to generate the proxy without parsing the file yourself despite of
whether document or rpc style is used.

From the server side, you could choose add the SoapRpcMethod attribute to
use rpc style like the following (removing the red line will use document
style):
[WebMethod]
[System.Web.Services.Protocols.SoapRpcMethodAttribute]
public string HelloWorld()
{
return "Hello World";
}

From the client side, you could apply the attribute similarly or let wsdl
to generate it for you automatically. For document style, the automatically
generated proxy would like the following:

[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.o
rg/HelloWorld", RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/",
Use=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string HelloWorld() {
object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));
}
For rpc style, it would like:

[System.Web.Services.Protocols.SoapRpcMethodAttribute("http://tempuri.org/He
lloWorld", RequestNamespace="http://tempuri.org/",
ResponseNamespace="http://tempuri.org/")]
public string HelloWorld() {
object[] results = this.Invoke("HelloWorld", new object[0]);
return ((string)(results[0]));
}

So, you could easily switch between both styles.

The following links might be helpful:

Understanding SOAP
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsoap/html
/understandsoap.asp
----------------------------------------------------------------------------
-----------------------------------------

Thanks.

0 new messages