472,995 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,995 software developers and data experts.

How to write custom serialization method in C# web service

Hi,

I have a C# web service client that talks to a JAVA application sever.
I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy
stub c# code. When I try to use c# client connect to application
server, I did not get the result in the C# client side, I used a soap
monitor to look at the SOAP messages that were exchanged, I can see
server returned a correct SOAP message, but the C# client failed to
deserialize the XML result back to the C# object.

I wonder if there is a way to write a custom XML deserializer to
populate the result back to C# object. The serialization part seemed to
be ok.

The following is the proxy code generated by wsdl.exe:

public class CommandServerService :
System.Web.Services.Protocols.SoapHttpClientProtoc ol {

/// <remarks/>
public CommandServerService() {
this.Url = "http://localhost:7001/services/CommandServer";
}

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAt tribute("",
Use=System.Web.Services.Description.SoapBindingUse .Literal,
ParameterStyle=System.Web.Services.Protocols.SoapP arameterStyle.Bare)]
[return:
System.Xml.Serialization.XmlElementAttribute("exec uteCommandReturn",
Namespace="http://webservice.foo.com")]
public TargetableCommand
executeCommand([System.Xml.Serialization.XmlElementAttribute(Names pace="http://webservice.foo.com")]
string in0,
[System.Xml.Serialization.XmlElementAttribute(Names pace="http://webservice.foo.com")]
TargetCommand in1) {
object[] results = this.Invoke("executeCommand", new object[] {
in0,
in1});
return ((TargetCommand)(results[0]));
}

....

}

The elements of "results[0]" are null.I used "Document/Literal" style
in wsdl document. I can get the result[0] with correct values populated
when I use "RP C encoding" style.

The generated proxy code does not tell me how System.Xml.Serialization
is called to handle serialization/deserialization, it seems that .Net
handles it automatically. I wonder how I can overwrite this behavoir by
supplying a custom serialization/deserialization method to populate the
result[0] with returning values. The following is the XML document
returned by the server:

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<executeCommandReturn xsi:type="ns1:LoginCommand"
xmlns="http://webservice.foo.com" xmlns:ns1="http://foo.bar.com">
<authenticationMethodId xsi:type="xsd:string"
xsi:nil="true"/>
<authenticationState
xsi:type="xsd:string">authenticated</authenticationState>
<authenticationStep xsi:type="xsd:string" xsi:nil="true"/>
<hiddenParameters
xsi:type="ns2:ArrayOf_tns5_AbstractParameterDTO"
xmlns:ns2="http://webservice.rsa.com"/>
<identitySourceGuid
xsi:type="xsd:string">000000000000000000001000d001 1000</identitySourceGuid>
<message xsi:type="ns3:MessageDTO" xsi:nil="true"
xmlns:ns3="http://data.authn.rsa.com"/>
<netAddress xsi:nil="true"/>
<parameters
xsi:type="ns4:ArrayOf_tns5_AbstractParameterDTO"
xmlns:ns4="http://webservice.rsa.com"/>
<policyGuid xsi:type="xsd:string" xsi:nil="true"/>
<principalGuid
xsi:type="xsd:string">ims.000000000000000000001000 d0021000</principalGuid>
<sessionId
xsi:type="xsd:string">b29b1b304358680a017385bef29f 4efb-k0PBDzXeDhxF</sessionId>
<usingTransientSession
xsi:type="xsd:boolean">false</usingTransientSession>
</executeCommandReturn>
</soapenv:Body>
</soapenv:Envelope>

The values returned by the server are in the message, but the client
failed to deserialize the values into result[0], which is
"TargetCommand" objec.

I am new to C#, any advice is appricated.

Thanks

Reply

Nov 12 '05 #1
0 2246

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Demetri | last post by:
I posted a similar question last week and got an answer but its not working. I have three projects in a solution. Project A is a library. Project B is a web service. Project C is a windows app. ...
0
by: psy000 | last post by:
Hi, I have a C# web service client that talks to a JAVA application sever. I use AXIS to generate the WSDL file, use wsdl.exe to generate proxy stub c# code. When I try to use c# client connect...
20
by: Nikolay Petrov | last post by:
Which is the best and convenient way to send/retrun custom types to/from Web Service? Serialization? The web service is not to be public accessible, it's a part of n-tier application. TIA
0
by: CJ Taylor | last post by:
hey everyone, thought I would ask this here because the web service groups seems pretty light on conversation. I'm buliding a web service, but keep getting this error. I understand the error,...
4
by: hellrazor | last post by:
Hi there, I'm trying to consume a web-service that is supposed to return a collection of a custom object. The web-service was not created with C# or VS.net. It was created with IBM VisualAge...
3
by: Zachary Turner | last post by:
Hello, I have a situation where I would like to perform custom serialization and deserialization of an existing .NET framework object (specifically, System.DateTime). Is there a common paradigm...
4
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but...
0
by: Bob L. | last post by:
Hi everyone, I am having a problem with svcutil.exe generating a method return type of System.Data.DataSet when the schema actually specifies my own custom DataSet. Here are the details... ...
11
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I have worked with application settings in VS2005 and C# for awhile, but usually with standard types. I have been trying to store a custom container/class/type in an application setting and I have...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.