.Net and VS with C# hi Andrei Ivanov

From: Date: Mon, 10 Mar 2003 01:19:44 +0000
Subject: .Net and VS with C# hi Andrei Ivanov
Groups: php.soap 
Request: Send a blank email to php-soap+get-460@lists.php.net to get a copy of this message
Hello All, I have been doing exactly what Andrei Ivanov has been attempting. With some success and some failures. This is not easy to say the least ... but it's for a good cause, putting the money back in the pockets of the coders instead of the richest men in the world. I have been looking at the benifits of soap and quick application building for destop apps using .NET ... don't get me wrong I love nux and open source all the way. Most of my applications have been built in PHP on linux and before that PERL and before that C. I like C# also because it's like C and Java combined and when they wrote it they didn't have to worry about backwards compatability. But MS Server and SQL costs are huge if you want a website that can handle more than 5 people ... so the way to go for desktop to server data sync is obviously using linux and apache etc. and SOAP to talk between the 2 is also the best option in my humble opinion. The problem is embeding a Web Service into VS that is not a IIS .NET SOAP Web Service, It's just not as easy if you make the server. I have used a linux box as a router between 2 windows boxes with tcpdump ansd ethereal to monitor packets between the client and server. This is how they generally work. The server side .asmx file reads the variables, data types and functions with a CLR assembly dirrective above them ie. [WebMethod] public string[] GetSpellingSuggestions(string word) A wsdl is generated that contains a discription of the available funtions variables and data types. IIS puts a wrapper around the webservice, in that if you call it directly through Internet Explorer you have html forms around every thing. When you right click on add reference to the VS explorer you then add a Web Reference ( Web Service ) with a URL to you Web Service. Here's where all the fun begins. VS calls the address you typed in and adds '?disco' i.e. http://server/services/Spell.asmx?disco unless you type in the address with a ?wsdl attached ?disco returns xml with the address of the wsdl i.e. <?xml version="1.0" encoding="utf-8" ?> - <discovery xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.xmlsoap.org/disco/"> <contractRef ref="http://server/services/Spell.asmx?wsdl" docRef="http://server/services/Spell.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> <soap address="http://server/services/Spell.asmx" xmlns:q1="http://tempuri.org/" binding="q1:SpellServiceSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" /> </discovery> The main diference with an IE WSDL and a non IE one is the way it references functions according to the WSDL by using a binding address to what appears to be sub folders <http:operation location="/GetSpellingSuggestions" /> notice the / now get this when they call a service they do this http://server/services/Spell.asmx/CheckSpelling?word=bruce Try getting a PHP script to both work as a parsable script and a folder ;) So If you saved a wsdl in a web directory from a VS generated file and add a reference in VS .NET it will show up as a real service, but you will find that compiles and then crashes when you call the Web Service due to it not getting a valid response as the WSDL described subfolder locations that will not work as yet. So the real key is to know your wsdl and create one that points correctly to the scripts. in a non IE manner i.e. http://api.google.com/GoogleSearch.wsdl the full verison with VS project in C# is at http://www.google.com/apis/ A helpful PHP routine that gets over the problem with a post/get value being empty returning a false is. <? if( count( $HTTP_GET_VARS ) > 0 ) { foreach( $HTTP_GET_VARS as $key => $value ) { if( $key == "wsdl" ){ $wsdl = true; } } } ?> This is my understanding to date, please someone correct me where I have made a mistake or over looked anything. comments please. Respect All Matt

« previous php.soap (#460) next »