473,795 Members | 3,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 CommandServerSe rvice :
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {

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

/// <remarks/>
[System.Web.Serv ices.Protocols. SoapDocumentMet hodAttribute("" ,
Use=System.Web. Services.Descri ption.SoapBindi ngUse.Literal,
ParameterStyle= System.Web.Serv ices.Protocols. SoapParameterSt yle.Bare)]
[return:
System.Xml.Seri alization.XmlEl ementAttribute( "executeCommand Return",
Namespace="http ://webservice.foo. com")]
public TargetableComma nd
executeCommand([System.Xml.Seri alization.XmlEl ementAttribute( Namespace="http ://webservice.foo. com")]
string in0,
[System.Xml.Seri alization.XmlEl ementAttribute( Namespace="http ://webservice.foo. com")]
TargetCommand in1) {
object[] results = this.Invoke("ex ecuteCommand", 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.Seri alization
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:Envelo pe
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 >
<executeCommand Return xsi:type="ns1:L oginCommand"
xmlns="http://webservice.foo. com" xmlns:ns1="http ://foo.bar.com">
<authentication MethodId xsi:type="xsd:s tring"
xsi:nil="true"/>
<authentication State
xsi:type="xsd:s tring">authenti cated</authenticationS tate>
<authentication Step xsi:type="xsd:s tring" xsi:nil="true"/>
<hiddenParamete rs
xsi:type="ns2:A rrayOf_tns5_Abs tractParameterD TO"
xmlns:ns2="http ://webservice.rsa. com"/>
<identitySource Guid
xsi:type="xsd:s tring">00000000 000000000000100 0d0011000</identitySourceG uid>
<message xsi:type="ns3:M essageDTO" xsi:nil="true"
xmlns:ns3="http ://data.authn.rsa. com"/>
<netAddress xsi:nil="true"/>
<parameters
xsi:type="ns4:A rrayOf_tns5_Abs tractParameterD TO"
xmlns:ns4="http ://webservice.rsa. com"/>
<policyGuid xsi:type="xsd:s tring" xsi:nil="true"/>
<principalGui d
xsi:type="xsd:s tring">ims.0000 000000000000000 01000d0021000</principalGuid>
<sessionId
xsi:type="xsd:s tring">b29b1b30 4358680a017385b ef29f4efb-k0PBDzXeDhxF</sessionId>
<usingTransient Session
xsi:type="xsd:b oolean">false</usingTransientS ession>
</executeCommandR eturn>
</soapenv:Body>
</soapenv:Envelop e>

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

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

Thanks

Reply

Nov 12 '05 #1
0 2343

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

Similar topics

4
1989
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. Project B and C make reference to project A in order to share the same library of classes. There is an abstract class in A and class that derives from the abstract one. Project B references project A and has a web method who's return type is...
0
1743
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 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...
20
1229
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
348
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, read a work around, but don't know if its the best approach. Here is a link to the error... at least a description. http://support.microsoft.com/default.aspx?scid=kb;en-us;814187 i'm confused though. I looked at Icollection, and there is no...
4
4514
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 Smalltalk 6. I haven't had problems consuming other web-services but c# seems to choke with "Collection" return types. The collection (or array) is supposed to contain three instances of a custom object called PsmWsResult, which has two variable...
3
2643
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 here, for how I can override the default behavior of DateTime serialization and provide my own? I want to use this custom serialized DateTime in many places, and don't want to provide custom serialization routines for every single object that...
4
5834
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 the resizing tool (in the designer) is offset both horizontally and vertically and when I put a control on it, as soon as I save, the designer throws an exception (but cannot be reproduced everytime) and the form cannot be loaded anymore unless...
0
2119
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... After carefully weighing the non-SOA practice of having a service expose DataSets (this is a small, internal project), I am trying to share the same custom DataSet class on both the client and the server by reference the same assembly (deployed to...
11
10153
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 seen erratic results. I am aware of one known defect where user classes do not show up in the list of types on the Property/Settings page in the visual designer and I am wondering if I am encountering some other peculiar issue, or if there are...
0
9519
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10001
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.