2017-01-16 11 views
0

おはようございます。私はSoapServer net winformアプリケーションから作成したPHP Webサービスを呼びたいと思っています。 PHPメソッドは、パラメータとしてXML文字列が供給し、JSONエンコードされた配列を返すされていますネットアプリケーションからPHP Webサービスを呼び出す

function getPolicy($contentsXml) { 
     if ($everyting->isOK) { 
      $resultArr = createResultArray(); 
     }else{ 
      // Process errors 
     } 
     $result = json_encode($resultArr); 
     return $result; 
    } 

私は、Visual Studioにウェブ参照を追加するために使用しているPHPのWebサービスに含まこれは、WSDLです:

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions name="XmlImportClaimWSDL" 
      targetNamespace="http://172.16.6.130/online/my.wsdl" 
      xmlns:tns="http://172.16.6.130/online/my.wsdl" 
      xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
      xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 

<wsdl:types> 
    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" > 
     <element name="getPolicy"> 
      <complexType> 
       <sequence> 
        <element minOccurs="0" maxOccurs="1" name="contentsXml" type="xsd:string" /> 
       </sequence> 
      </complexType> 
      </element> 
      <element name="getPolicyResponse"> 
      <complexType> 
       <sequence> 
        <element minOccurs="0" maxOccurs="1" name="contentsXml" type="xsd:json" /> 
       </sequence> 
      </complexType> 
     </element> 
    </xsd:schema> 
</wsdl:types> 
    <wsdl:message name="getPolicyRequest"> 
    <wsdl:part name="requestParam" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:message name="getPolicyResponse"> 
    <wsdl:part name="responseParam" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:portType name="ServerClaimSoapType"> 
    <wsdl:operation name="getPolicy"> 
     <wsdl:input message="tns:getPolicyRequest" /> 
     <wsdl:output message="tns:getPolicyResponse" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="ServerClaimSoapBinding" type="tns:ServerClaimSoapType"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> 
    <wsdl:operation name="getPolicy"> 
     <soap:operation soapAction="http://php-server-address/"/> 
    <wsdl:input> 
     <soap:body use="literal" /> 
     </wsdl:input> 
    <wsdl:output> 
     <soap:body use="literal" /> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="ServerClaim"> 
    <wsdl:port name="ServerClaimSoap" binding="tns:ServerClaimSoapBinding"> 
     <soap:address location="http://php-server-address/phpSoapService.php" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

私はfiddlerから見ることができるように、PHPはパラメータを受け取り、正しいjsonオブジェクトを送り返しますが、ネットコードの結果は常にnullです。ネットのコードは次のとおりです。

PhpSoapObject client = new PhpSoapObject(); 
var result = client.getPolicy(PredifenedXmlString); 

ので結果変数は常にnullです。私の推測はwsdlバインディングです。私はこの状況についてたくさん調べました。私は、nusoapなしでネットフレームワークでPHP Webサービスを使用することは非常によく文書化されて認識しています。このような長い質問を読んでくれてありがとう。

答えて

0

多くの試験の後、すべてが現在動作しています。 Eclipseのwsdlエディタのおかげで、素晴らしいツールを中継します。 PHPのWSDLのように定義する必要があります。

<?xml version="1.0" encoding="utf-8"?> 
<wsdl:definitions name="XmlImportClaimWSDL" 
      targetNamespace="http://172.16.6.130/online/" 
      xmlns:tns="http://172.16.6.130/online/" 
      xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
      xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
      xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> 

<wsdl:types> 
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://172.16.6.130/online/" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" > 
    <xsd:element name="getPolicy"> 
      <xsd:complexType> 
       <xsd:sequence> 

        <xsd:element minOccurs="0" maxOccurs="1" name="contentsXml" type="xsd:string" /> 
       </xsd:sequence> 
      </xsd:complexType> 
      </xsd:element> 
      <xsd:element name="getPolicyResponse"> 
      <xsd:complexType> 
       <xsd:sequence> 

        <xsd:element minOccurs="0" maxOccurs="1" name="getPolicyResult" type="xsd:string" /> 
       </xsd:sequence> 
      </xsd:complexType> 
     </xsd:element> 
    </xsd:schema> 
</wsdl:types> 
    <wsdl:message name="getPolicyRequest"> 
    <wsdl:part name="requestParam" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:message name="getPolicyResponse"> 
    <wsdl:part name="responseParam" type="xsd:string"/> 
    </wsdl:message> 
    <wsdl:portType name="ServerClaimSoapType"> 
    <wsdl:operation name="getPolicy"> 
     <wsdl:input message="tns:getPolicyRequest" /> 
     <wsdl:output message="tns:getPolicyResponse" /> 
    </wsdl:operation> 
    </wsdl:portType> 
    <wsdl:binding name="ServerClaimSoapBinding" type="tns:ServerClaimSoapType"> 
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/> 
    <wsdl:operation name="getPolicy"> 
     <soap:operation soapAction="http://172.16.6.130/online/getPolicy" /> 
     <wsdl:input> 
      <soap:body use="literal" namespace="http://172.16.6.130/online/"/> 
     </wsdl:input> 
     <wsdl:output> 
      <soap:body use="literal" namespace="http://172.16.6.130/online/"/> 
     </wsdl:output> 
    </wsdl:operation> 
     </wsdl:output> 
    </wsdl:operation> 
    </wsdl:binding> 
    <wsdl:service name="ServerClaim"> 
    <wsdl:port name="ServerClaimSoap" binding="tns:ServerClaimSoapBinding"> 
     <soap:address location="http://172.16.6.130/phpSoapService.php" /> 
    </wsdl:port> 
    </wsdl:service> 
</wsdl:definitions> 

主な問題は、が不足して体の名前空間を結合スキーマの名前空間incorectました。これが誰かを助けることを願っています。 P.P. Stackoverflowは、あなたの問題を検索するための最良の場所です。

関連する問題