Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Consuming PHP-webservice with C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas Mueller - 17 Jan 2008 16:25 GMT
Hi,
I'm currently working on C# code consuming a PHP-webservice
(soapserver-class of PHP5). A PHP test-client worked fine and achieved
the requested data from the service's server.

Using the wsdl-file of the webservice, wsdl.exe generated a C#-proxy
class errorlessly. I then tried to instantiate the proxy class to access
the service:

waClient.waService was = new waClient.waService();
waClient.tCourseDescription cd = was.getCourseByKey("12345");

It compiles without errors or warnings but after calling the
getCourseByKey-methode, it throughs an exception, reporting that the
given type is unknown:

(Name=map, Namespace=Namespace='http://xml.apache.org/xml-soap', at
<courseDescription xmlns=''>

Using a traffic sniffer, I found out, that the php webservice-server
sends the following response to the C# client instance:

###
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:course"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://xml.apache.org/xml-soap"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>

<ns1:getCourseByKeyResponse>
  <courseDescription xsi:type="ns2:map">
    <item>
      <key xsi:type="xsd:string">language</key>
      <value xsi:type="xsd:string">de</value>
    </item>
    [..]
  </courseDescription>
</ns1:getCourseByKeyResponse>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
###

C# seems not to be able to deserialize the map-element of the apache.org
 namespace. What can I do get the respons data?

Is it possible to get the plain xml-response in C# (to deserialize it
manually to the target object)? How?

Thanks a lot for any hint!
Thomas
Arne Vajhøj - 18 Jan 2008 01:40 GMT
> I'm currently working on C# code consuming a PHP-webservice
> (soapserver-class of PHP5). A PHP test-client worked fine and achieved
[quoted text clipped - 48 lines]
> Is it possible to get the plain xml-response in C# (to deserialize it
> manually to the target object)? How?

SOAP and WSDL allows you to make technology independent
web services - it does not force you to do so.

Using other standards like WS-I Basic Profile is necessary
to enforce portability.

My guess is that the PHP service is doing something PHP'ish and
that is why .NET can not handle it.

If changing the PHP is an option we could try and loop at the
PHP code, the WSDL and the SOAP to come up with a solution.

If changing the PHP is not an option, then you could fallback to
(Http)WebRequest and write and read the XML manually.

Sniff what the PHP client send and receive and code from that.

I think I have some C# code parsing SOAP XML somewhere if you
are interested.

Arne

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.