I am trying to create a Web Service where parameters chosen from a web-page are sent to a standalone.exe written in C# which controls a CAD package installed on the server. The CAD package then generates an image based on the selected parameters chosen by the user on the front-end web-page. In a nut shell I need:
From what I understand, I need SOAP implementation with a visible WSDL. I had no problems running through tutorials and creating my own SOAP and WSDL and communicating on my local and remote servers between my own PHP functions.
Now I am trying to get a PHP written SOAP to be consumed by a C# standalone and that's where I am getting lost. I am relatively new to SOAP and WSDL but I understand the basics and functions of each. Additionally, I started using NUSOAP for my wsdl generation.
Is there a similar code package that allows the creation of WSDL files from c# methods that allow for SOAP connectivity?
Also, my client and the web page will always know the WSDL and the required parameters to be sent. Essentially, this is just a gateway between web and the CAD package.
Here is the Wheezly McDizzle
<?xml version="1.0" encoding="UTF-8"?>
<definitions
xmlns:typens="urn:getBlockedIP"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
name="getBlockedIP"
targetNamespace="urn:getBlockedIP">
<types></types>
<message name="getBlockedIP">
<part name="idNumber" type="xsd:string"/>
</message>
<message name="getBlockedIPResponse">
<part name="ipAddress" type="xsd:string"/>
</message>
<portType name="blockedIPPort">
<operation name="getBlockedIP">
<input message="typens:getBlockedIP" />
<output message="typens:getBlockedIPResponse"/>
</operation>
</portType>
<binding name="blockedIPBinding" type="typens:blockedIPPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name = "getBlockedIP" >
<soap:operation soapAction = "urn:blockedIPAction" />
<input>
<soap:body namespace="urn:getBlockedIP" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output>
<soap:body namespace="urn:getBlockedIP" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="getBlockedIPService">
<port name="blockedIPPort" binding="blockedIPBinding">
<soap:address location="http://mysite.com/xdata/blockedip_api.php"/>
</port>
</service>
</definitions>
The method that this is testing is a simple array fetch with a single parameter. It is just an array with 25 elements that contains blocked IPs and the user picks a number between 1-25 and the method spits out the IP related to that location in the array.
I mimicked the method in C# as a command prompt program with Console.WriteLine
and Console.ReadLine()
. (That is incorrect obviously as the C# program has to grab the parameters from the XML file rather that any user input)
So now I am stuck - my head is all jumbled up with WhizCheese Dulls and SOAP and XML. I am confused as to where to go from here. I am pro with front and back end Web development but still wet behind the ears when it comes to the .NET framework.
Essentially what I would like is someone to point me in the right direction to finally accomplish my first stated goal in this project. Is it even possible with the way i am doing things? Maybe SOAP is not the correct path? I am also getting confused as to how to send the parameters to a standalone c# .exe and have it consume it (like a hamburger...mmmmmmm).
Here is my soap instantiations in PHP on the remote server:
Client:
// WSDL location to be used with a WSDL instantiation of SOAP
$namespace = 'http://mysite.com/xdata/blockedip.wsdl';
// Parameters are easier sent as an array with associative keys
$params = array('arrayNum' => $number);
// include soap client (php.ini include_path set to installed PEAR location)
require_once 'SOAP/Client.php';
// create SOAP Client with an exposed WSDL location
$wsdl = new SOAP_WSDL($namespace);
//communicate with server, WSDL
$SoapClient = $wsdl->getProxy();
//call method with parameters
$ip = $SoapClient->call("getBlockedIP", $params);
Server:
// include soap server and create server object
require_once 'SOAP/Server.php';
$soapServer = new SOAP_Server();
$server->_auto_translation = true;
// create class with desired method
$blockedip = new SoapTestClass();
// add class and namespace schema
$soapServer->addObjectMap($blockedip, 'http://schemas.xmlsoap.org/soap/envelope/');
// respond with raw post
$soapServer->service($GLOBALS['HTTP_RAW_POST_DATA']);
If you need anything else, ill gladly share. Thank you for taking the time to read this and for any help you can offer! I Greatly appreciate it.
UPDATE:
From what i have been reading maybe i have to turn on metadata yet i have no idea where this can be done?
UPDATE:
I have been using NUSOAP to generate my WSDL files from php methods and connecting them to VISUAL STUDIO 2010 C# and they have been working. I am now stuck on reversing the process. I need php to send parameters to a C# method and have that .exe return something.
I went with a C# program that connects to MySQL and have it periodically check for new entries in a table.