2016-05-23 11 views
1

SOAP要求を一部のサーバーに投稿する必要があります。 次のように私がいることを正確にSOAPリクエストの右の例を知っている:私はPHP 5.3で同じコードを作成しようとしているPHPで非wsdl SOAPリクエスト

public partial class frmMain : Form 
{ 
    public frmMain() 
    { 
     InitializeComponent(); 
    } 

    public EndpointAddress EndPointAddr { 
     get { return 
      new EndpointAddress("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl"); 
     } 
    } 

    private void btnSend_Click(object sender, EventArgs e) 
    { 
     ServicePointManager.ServerCertificateValidationCallback = 
      new RemoteCertificateValidationCallback(IgnoreCertificateErrorHandler); 

     ServicePointManager.Expect100Continue = false; 


     ServiceICreditTest.CreateOrderResponse response = new CreateOrderResponse(); 


     ScroogeSiteGist client = new ScroogeSiteGist(Binding(), EndPointAddr); 
     shortApplicationBroker shortAp = new shortApplicationBroker() 
     { 
      agreeId = 3155, 
      PIB = "John Doe", 
      stateCode = "1234567890", 
      formId = 55, 
      telephone = "1511528945" 

     }; 
     //response = client.CreateOrder("1012021013"); 
     response = client.CreateOrderBroker(shortAp); 

     txtText.Text = string.Format("id = {0} ErrorId = {1}", response.OrderId, response.ReturnValue); 

    } 
} 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Body> 
<CreateOrderBroker xmlns="http://tempuri.org/"> 
<shortApp xmlns:a="http://schemas.datacontract.org/2004/07/ScroogeCbformsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<a:PIB>John Doe</a:PIB> 
<a:agreeId>3155</a:agreeId> 
<a:formId>55</a:formId> 
<a:stateCode>1234567890</a:stateCode> 
<a:telephone>1511528945</a:telephone> 
</shortApp> 
</CreateOrderBroker> 
</s:Body> 
</s:Envelope> 

はまた、私はC#の例を働いています

<?php 
$client = new SoapClient("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl", array('soap_version' => SOAP_1_1, 'trace' => 1)); 

$params = array(
    'agreeId' => 3155, 
    'PIB' => 'John Doe', 
    'stateCode' => '3289013768', 
    'formId' => 55, 
    'telephone' => '0661254877' 
); 

$client->CreateOrderBroker($params); 

しかし、このコードからの要求とコールバックは次です:

<?php 
... 
echo "REQUEST:<pre>".htmlspecialchars($client->__getLastRequest()) ."</pre>"; 
echo "CALLBACK:<pre>".htmlspecialchars($client->__getLastResponse())."</pre>"; 

REQUEST:

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/"> 
<SOAP-ENV:Body><ns1:CreateOrderBroker/> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

CALLBACK:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> 
<s:Body><CreateOrderBrokerResponse xmlns="http://tempuri.org/"><CreateOrderBrokerResult xmlns:a="http://schemas.datacontract.org/2004/07/ScroogeCbformsService" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<a:OrderId>0</a:OrderId> 
<a:ReturnValue>Object reference not set to an instance of an object.</a:ReturnValue> 
</CreateOrderBrokerResult> 
</CreateOrderBrokerResponse> 
</s:Body> 
</s:Envelope> 

要求の本体が空であるようです。

この意味は? wsdl-modeでの呼び出しと要求本体が空の場合、wsdl-schemaは壊れています。 wsdlが壊れている場合、最初の正しいSOAPリクエストを手動で構築する方法は何ですか?誰かが例を挙げることはできますか? また、最初の右側のSOAPリクエストで与えられたデータは、このリクエストを手動で構築するのに十分ですか?または私はいくつかの余分な(名前空間など)を必要とする

答えて

0

次のコードを試してみてください。このコード

$client = new SoapClient("https://194.126.180.186:77/ScroogeCbForms.svc?wsdl", array('soap_version' => SOAP_1_1, 'trace' => 1)); 

class shortApp { 
    function __construct() 
    { 
     $this->agreeId = 3155; 
     $this->PIB = 'John Doe'; 
     $this->stateCode = '3289013768'; 
     $this->formId = 55; 
     $this->telephone = '0661254877'; 
    } 
} 

$sa = new shortApp(); 
$shortApp = new SoapVar($sa, SOAP_ENC_OBJECT, 'shortApp', 'http://soapinterop.org/xsd'); 
$response = $client->CreateOrderBroker(new SoapParam($shortApp, 'shortApp')); 

をあなたの次のリクエスト与える必要があります。

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://soapinterop.org/xsd" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
    <SOAP-ENV:Body> 
     <ns1:CreateOrderBroker> 
      <shortApp xsi:type="ns2:shortApp"> 
       <agreeId xsi:type="xsd:int">3155</agreeId> 
       <PIB xsi:type="xsd:string">John Doe</PIB> 
       <stateCode xsi:type="xsd:string">3289013768</stateCode> 
       <formId xsi:type="xsd:int">55</formId> 
       <telephone xsi:type="xsd:string">0661254877</telephone> 
      </shortApp> 
     </ns1:CreateOrderBroker> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 
+0

をおかげで、このコードは正確にリクエストの上にいます。しかし、応答は古いままです: 'code'オブジェクト参照がオブジェクトのインスタンスに設定されていません。 これは、質問が私の質問の始めに正確な正しい例でなければならないことを意味します。 全く同じものを変更するにはどうすればよいですか? –