473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 2294

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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.