2017-02-20 5 views
0

PHPでSOAP関数を呼び出そうとしていますPHPでSOAP関数を呼び出そうとしたときにエラーが発生しました

エラー:

Server was unable to process request. ---> Object reference not set to an instance of an object

XML:あなたはより多くの情報をご希望の場合

$client = new SoapClient("http://example.com/example.asmx?WSDL", array('trace' => 1));  

$card = array(
     'cardnumber' => 'example card number', 
     'pincode' => 'example pin code' 
    ); 

    try { 
     $result = $client->__soapCall('GetCardInfo', $card); 
     print_r($result); 
    } 

    catch (SoapFault $q) 
    { 
     print_R($q); 
    } 

POST /example.com/example.asmx HTTP/1.1 
Host: URL 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://www.example.com/action" 

<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <soap:Header> 
    <AuthenticationHeader xmlns="http://www.example.com/"> 
     <username>string</username> 
     <password>string</password> 
     <Id>long</Id> 
    </AuthenticationHeader> 
    </soap:Header> 
    <soap:Body> 
    <GetCardInfo xmlns="http://www.example.com/"> 
     <cardnumber>string</cardnumber> 
     <pincode>string</pincode> 
    </GetCardInfo> 
    </soap:Body> 
</soap:Envelope> 

は、私は、関数を呼び出すために、このコードを使用しています、 私に聞いてください。私はこのコミュニティには新しい人です。

ありがとうございます。

+0

あなたは確かにエラーはプロバイダから来ていませんか? –

答えて

0

私はそれを解決しました。私は、stdClassオブジェクトにSoapHeaderを配置し、それを配列にキャストしなければなりませんでした。私はそれがなぜ機能するのか分かりませんが、それはありません。

関連する問題