Porting Apache-SOAP java client into C# 
Author Message
 Porting Apache-SOAP java client into C#

Hi forks,

Is there anyone succeeded porting Apache-SOAP java client into C#
client?  In my situation, I'd like to make a C# client which
communicates with Apache-SOAP webservice.

So, I'm trying to port the 'addressbook' sample project which included
in Apache-SOAP 2.3, based on the article "A C# SOAP Apache Client"
( http://www.*-*-*.com/ )
However, there are little difference:  a SOAP message in 'addressbook'
sample project describes nested class;  while primitive types (e.g.
string) found in the latter example.

Following is the source code of GetAddress.cs(written by me), which is
the counterpart of GetAddress.java in 'addressbook' sample project:

namespace samples.addressbook
        using System;
        using System.Diagnostics;
        using System.Xml;
        using System.Xml.Serialization;
        using System.Web.Services;
        using System.Web.Services.Protocols;

        public class GetAddress:
                public GetAddress()
                        this.Url = "http://localhost:8080/soap/servlet/rpcrouter";

                public string getAddressFromName(string name)
                        object [] results = null;
                                results = (Address [])(this.Invoke("getAddressFromName",new
object[] {name} ));
                        catch (Exception e)
                                Console.WriteLine("Generic Exception Handler: {0}", e.ToString());
                        return ((string)(results.ToString()));

                public static void  Main(System.String[] args)
                        GetAddress getAddress = new GetAddress();
                        Console.WriteLine((string)getAddress.getAddressFromName("John B.


Anyway above code doesn't work... error messages are:
Generic Exception Handler: System.InvalidOperationException: There is
an error in XML document (16,10). ---> System.InvalidCastException:
Cannot assign object of type System.Xml.XmlNode[] to an object of type
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read5_getAddressFromName
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
   at samples.addressbook.GetAddress.getAddressFromName(String name)

And these are the SOAP request/response for above case:
POST /soap/servlet/rpcrouter HTTP/1.1User-Agent: Mozilla/4.0
(compatible; MSIE 6.0; MS Web Services Client Protocol
1.0.3705.0)Content-Type: text/xml; charset=utf-8SOAPAction:
""Content-Length: 624Expect: 100-continueConnection: Keep-AliveHost:<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap=" http://www.*-*-*.com/ ;
xmlns:soapenc=" http://www.*-*-*.com/ ;
xmlns:tns=" http://www.*-*-*.com/ :8070/soap/servlet/rpcrouter"
xmlns:types=" http://www.*-*-*.com/ :8070/soap/servlet/rpcrouter/encodedTypes"
xmlns:xsi=" http://www.*-*-*.com/ ;
xmlns:xsd=" http://www.*-*-*.com/ ;><soap:Body
soap:encodingStyle=" http://www.*-*-*.com/ ;><q1:getAddressFromName
xmlns:q1="urn:AddressFetcher"><name xsi:type="xsd:string">John B.

HTTP/1.1 100 ContinueHTTP/1.1 200 OKContent-Type: text/xml;
charset=utf-8Content-Length: 927Date: Thu, 20 Jun 2002 12:46:41
GMTServer: Apache Tomcat/4.0.3 (HTTP/1.1 Connector)Set-Cookie:
version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope
xmlns:SOAP-ENV=" http://www.*-*-*.com/ ;
xmlns:xsi=" http://www.*-*-*.com/ ;
xmlns:xsd=" http://www.*-*-*.com/ ;>
<ns1:getAddressFromNameResponse xmlns:ns1="urn:AddressFetcher"
SOAP-ENV:encodingStyle=" http://www.*-*-*.com/ ;>
<return xmlns:ns2="urn:xml-soap-address-demo" xsi:type="ns2:address">
<phoneNumber xsi:type="ns2:phone">
<exchange xsi:type="xsd:string">456</exchange>
<areaCode xsi:type="xsd:int">123</areaCode>
<number xsi:type="xsd:string">7890</number>
<zip xsi:type="xsd:int">12345</zip>
<streetNum xsi:type="xsd:int">123</streetNum>
<streetName xsi:type="xsd:string">Main Street</streetName>
<state xsi:type="xsd:string">NY</state>
<city xsi:type="xsd:string">Anytown</city>


Can anyone give me a hint?

Koo Min

Mon, 06 Dec 2004 21:02:18 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Getting Microsoft SOAP to work with an Apache SOAP server

2. Q: calling Java SOAP services from C# : example?

3. Where to start for a C# SOAP Client....

4. C# as a SOAP client

5. Porting Java Apps To C#

6. java to C# and C# to java converters

7. Interoperability of C# webservice with Java Client

8. Can C# client talk to a Java server ??

9. ATL Soap Client bugs

10. VC7 - ATL Soap Client

11. Need help building a .NET soap client for XML for Analysis server

12. generic Soap webservice proxy client


Powered by phpBB® Forum Software