duanqi6274 2011-11-18 20:41
浏览 48

PHP SoapServer返回的字符串值未被.Net客户端接收

I am using the WSDL document automatically generated by Visual Studio 2010 (ie. from the "HelloWorld" application that is created when you create a new web service application in Visual Studio.) But I am needing to develop the web service in PHP, so I am using this WSDL document with PHP SoapServer. I will copy the WSDL document here:

<?xml version="1.0" encoding="utf-8"?>

<wsdl:definitions 
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"   
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" 
xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://tempuri.org/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">

<wsdl:types>
   <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
      <s:element name="HelloWorld">
         <s:complexType />
      </s:element>
      <s:element name="HelloWorldResponse">
         <s:complexType>
            <s:sequence>
               <s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
            </s:sequence>
         </s:complexType>
      </s:element>
   </s:schema>
</wsdl:types>

<wsdl:message name="HelloWorldSoapIn">
   <wsdl:part name="parameters" element="tns:HelloWorld" />
</wsdl:message>
<wsdl:message name="HelloWorldSoapOut">
   <wsdl:part name="parameters" element="tns:HelloWorldResponse" />
</wsdl:message>

<wsdl:portType name="Service1Soap">
  <wsdl:operation name="HelloWorld">
     <wsdl:input message="tns:HelloWorldSoapIn" />
     <wsdl:output message="tns:HelloWorldSoapOut" />
   </wsdl:operation>
</wsdl:portType>


<wsdl:binding name="Service1Soap" type="tns:Service1Soap">
   <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
   <wsdl:operation name="HelloWorld">
      <soap:operation soapAction="http://tempuri.org/HelloWorld" style="document" />
      <wsdl:input>
         <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
         <soap:body use="literal" />
      </wsdl:output>
   </wsdl:operation>
</wsdl:binding>

<wsdl:binding name="Service1Soap12" type="tns:Service1Soap">
   <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
   <wsdl:operation name="HelloWorld">
      <soap12:operation soapAction="http://tempuri.org/HelloWorld" style="document" />
      <wsdl:input>
         <soap12:body use="literal" />
      </wsdl:input>
      <wsdl:output>
         <soap12:body use="literal" />
      </wsdl:output>
   </wsdl:operation>
</wsdl:binding>

<wsdl:service name="Service1">
   <wsdl:port name="Service1Soap" binding="tns:Service1Soap">
      <soap:address location="helloworld_server.php" />
   </wsdl:port>
   <wsdl:port name="Service1Soap12" binding="tns:Service1Soap12">
      <soap12:address location="helloworld_server.php" />
   </wsdl:port>
</wsdl:service>

</wsdl:definitions>

My PHP SoapServer code looks like this:

function HelloWorld()
{
   return "Hello world!";
}

$server = new SoapServer( 'helloworld.wsdl' );
$server->addFunction('HelloWorld');
try {
   $server->handle();
}
catch (Exception $e) {
   $server->fault('Sender', $e->getMessage());
}

When I try call this soap service with a .Net client, I am getting an empty string returned. Does anyone know what is going wrong with this simple example?

UPDATE:

This specifically seems to be a problem with communicating with a .Net client from the PHP server. I have tested with a PHP client and I get the message returned by the server in the PHP client. But for some reason the .Net client gets an empty string returned. For the .Net client, I created a simple WinForms application, added a web reference to the php soap server. The web reference gets added correctly and shows the API. I put one button on the form with the following click handle:

private void button1_Click(object sender, EventArgs e)
{
    WebReference.Service1 srv = new WebReference.Service1();
    string result = srv.HelloWorld();
    MessageBox.Show(result);
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类