duancaoqin6683 2013-04-17 19:05 采纳率: 0%
浏览 94
已采纳

将PEAR SOAP与WSDL连接到C#standalone .exe

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:

  1. User selects two parts
  2. Selected parts are sent to C# .exe
  3. C# runs CAD package, connects the parts, returns image of two parts
  4. User sees image

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.

  • 写回答

4条回答 默认 最新

  • dsa1234569 2013-05-03 23:59
    关注

    I went with a C# program that connects to MySQL and have it periodically check for new entries in a table.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划