简体   繁体   English

如何使用php SoapClient发送肥皂请求?

[英]How can I send the soap request with php SoapClient?

I want to send the below object using soap with php SoapClient. 我想使用肥皂与PHP SoapClient发送以下对象。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:adin="http://3e.pl/ADInterface">
   <soapenv:Header/>
   <soapenv:Body>
      <adin:queryData>
         <adin:ModelCRUDRequest>
            <adin:ModelCRUD>
               <adin:serviceType>ReadSalesOrder</adin:serviceType>
               <adin:TableName>XX_RV_Interface_Order</adin:TableName>
               <adin:RecordID>0</adin:RecordID>
               <adin:Filter></adin:Filter>
               <adin:Action>Read</adin:Action>
               <!--Optional:-->
               <adin:DataRow>
                  <!--Zero or more repetitions:-->
                  <adin:field type="integer" column="C_BPartner_ID" lval="" disp="" edit="" error="" errorVal="">
                     <adin:val>1000643</adin:val>
                  </adin:field>
               </adin:DataRow>
            </adin:ModelCRUD>
            <adin:ADLoginRequest>
               <adin:user>username</adin:user>
               <adin:pass>password</adin:pass>
               <adin:lang>zh_CN</adin:lang>
               <adin:ClientID>1000000</adin:ClientID>
               <adin:RoleID>1000029</adin:RoleID>
               <adin:OrgID>1000000</adin:OrgID>
               <adin:WarehouseID>1000023</adin:WarehouseID>
            </adin:ADLoginRequest>
         </adin:ModelCRUDRequest>
      </adin:queryData>
   </soapenv:Body>
</soapenv:Envelope>

I have tried the below: 我尝试了以下方法:

$wsdl = 'http://example.com/ModelADService?wsdl';
$client = new SoapClient($wsdl);
$result = $client->__soapCall('queryData', array(
    'ModelCRUDRequest' => array(
        'ModelCRUD' => array(
            'serviceType' => 'ReadSalesOrder',
            'TableName' => 'XX_RV_Interface_Order',
            'RecordID' => 0,
            'Filter' => '',
            'Action' => 'Read',
            'DataRow' => array(
                'field' => array(
                    'type' => 'integer',
                    'column' => 'C_BPartner_ID',
                    'lval' => '',
                    'disp' => '',
                    'edit' => '',
                    'error' => '',
                    'errorVal' => '',
                    'val' => 1000643,
                )
            )
        ),
        'ADLoginRequest' => array(
            'user' => 'username',
            'pass' => 'password',
            'lang' => 'zh_CN',
            'ClientID' => 1000000,
            'RoleID' => 1000029,
            'OrgID' => 1000000,
            'WarehouseID' => 1000023,
            'stage' => '',
        ),
    ),
));

var_dump($result);

Fatal error : Uncaught SoapFault exception: [soap:Client] Parameter ModelCRUDRequest does not exist! 致命错误 :未捕获的SoapFault异常:[soap:Client]参数ModelCRUDRequest不存在!

必须先初始化SOAP客户端
$client = new SoapClient($wsdl);

You're problem isn't with the soap call, but with the data you're sending or the receiving soap. 您的问题不在于soap呼叫,而是与您正在发送或接收的数据有关。 soap is frustrating because you're calling a function on another server, and any errors thrown on that server trigger on your server. soap之所以令人沮丧,是因为您要在另一台服务器上调用一个函数,并且该服务器上引发的任何错误都会在您的服务器上触发。 So if their function has a fatal error, your code will have a fatal error. 因此,如果它们的函数出现致命错误,则您的代码将出现致命错误。 This is why all soap calls must be inside a try catch. 这就是为什么所有肥皂呼叫都必须放在try catch中的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM