2013-06-18 97 views
0

林調用Web服務(C#),使用nusoap_client.The PHP代碼是如下C#web服務返回null其從PHP

$client = new nusoap_client('http://localhost/TestWebService/TestWebService.asmx?WSDL','TRUE'); 
//echo("execute". $client); 
$result = $client->call('GenerateRandomNumber'); 
//echo("executerandomn".$result); 
$return=redirectpage($result); //redirectpage() function redirects the user based on the random number generated. 

的產生之間(圖1和5)從PHP代碼的隨機數稱爲函數GenerateRandomNumber()返回null.I嘗試瀏覽webservice分開它的工作,但不通過php調用時。

創建的WSDL低於

<?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="GenerateRandomNumber"> 
<s:complexType /> 
</s:element> 
<s:element name="GenerateRandomNumberResponse"> 
<s:complexType> 
<s:sequence> 
<s:element minOccurs="1" maxOccurs="1" name="GenerateRandomNumberResult" type="s:int" /> 
     </s:sequence> 
    </s:complexType> 
    </s:element> 
</s:schema> 
</wsdl:types> 
<wsdl:message name="GenerateRandomNumberSoapIn"> 
<wsdl:part name="parameters" element="tns:GenerateRandomNumber" /> 
</wsdl:message> 
<wsdl:message name="GenerateRandomNumberSoapOut"> 
<wsdl:part name="parameters" element="tns:GenerateRandomNumberResponse" /> 
</wsdl:message> 
<wsdl:portType name="TestWebServiceSoap"> 
<wsdl:operation name="GenerateRandomNumber"> 
    <wsdl:input message="tns:GenerateRandomNumberSoapIn" /> 
    <wsdl:output message="tns:GenerateRandomNumberSoapOut" /> 
    </wsdl:operation> 
     </wsdl:portType> 
<wsdl:binding name="TestWebServiceSoap" type="tns:TestWebServiceSoap"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="GenerateRandomNumber"> 
    <soap:operation soapAction="http://tempuri.org/GenerateRandomNumber" 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="TestWebServiceSoap12" type="tns:TestWebServiceSoap"> 
    <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" /> 
    <wsdl:operation name="GenerateRandomNumber"> 
    <soap12:operation soapAction="http://tempuri.org/GenerateRandomNumber" 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="TestWebService"> 
    <wsdl:port name="TestWebServiceSoap" binding="tns:TestWebServiceSoap"> 
    <soap:address location="http://localhost/TestWebService/TestWebService.asmx" /> 
     </wsdl:port> 
     <wsdl:port name="TestWebServiceSoap12" binding="tns:TestWebServiceSoap12"> 
    <soap12:address location="http://localhost/TestWebService/TestWebService.asmx" /> 
    </wsdl:port> 
    </wsdl:service> 
    </wsdl:definitions> 

請幫助。

+0

請勿使用SOAP。 – Epoc

+0

你可以用電話代替肥皂嗎,我該用什麼? – user1942809

+0

以RESTful方式構建您的webservice,您可以從http://www.petefreitag.com/item/431.cfm或http://www.xfront.com/REST-Web-Services.html中找到起點。這裏是一個C#庫,它可能很有趣:http://restsharp.org/ – Epoc

回答

1

HI也許這個WSDL到PHP轉換器可以幫助你http://www.wsdltophp.com/它可以使函數發出請求並獲得正確的響應。