SOAP 和 PHP。我如何检索此响应?

SOAP and PHP. How do I retrieve this response?

我现在被一个问题困住了一段时间。我正在尝试让这个在 SOAP UI 中有效的请求在 PHP 中有效:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:otp="OTPNA">
<soapenv:Header/>
<soapenv:Body>
  <otp:ProductRequestIn>
     <otp:fromRole>
        <otp:PartnerRoleDescription>
           <otp:ContactInformation>
              <otp:contactName>
                 <otp:FreeFormText lang="NL">?</otp:FreeFormText>
              </otp:contactName>
              <otp:EmailAddress>?</otp:EmailAddress>
              <!--Optional:-->
              <otp:facsimileNumber>
                 <otp:CommunicationsNumber>?</otp:CommunicationsNumber>
              </otp:facsimileNumber>
              <otp:telephoneNumber>
                 <otp:CommunicationsNumber>?</otp:CommunicationsNumber>
              </otp:telephoneNumber>
           </otp:ContactInformation>
           <otp:GlobalPartnerRoleClassificationCode>?  </otp:GlobalPartnerRoleClassificationCode>
           <otp:PartnerDescription>
              <otp:BusinessDescription>
                 <!--Optional:-->
                 <otp:GlobalBusinessIdentifier>-BZNSID-</otp:GlobalBusinessIdentifier>
                 <!--Optional:-->
                 <otp:GlobalSupplyChainCode>?</otp:GlobalSupplyChainCode>
                 <!--Optional:-->
                 <otp:businessName>
                    <otp:FreeFormText lang="?">?</otp:FreeFormText>
                 </otp:businessName>
              </otp:BusinessDescription>
              <otp:GlobalPartnerClassificationCode>?   </otp:GlobalPartnerClassificationCode>
           </otp:PartnerDescription>
        </otp:PartnerRoleDescription>
     </otp:fromRole>
     <otp:Authentication>
        <otp:Username>-USERNAME-</otp:Username>
        <otp:Password>-PASSWORD-</otp:Password>
     </otp:Authentication>
     <otp:productIdentifier type="PDI">---</otp:productIdentifier>
     <otp:lang>NL</otp:lang>
     <otp:ProductInformationType>RIC</otp:ProductInformationType>
     <otp:RequestedPartner>
        <otp:PartnerID>-PARTNERID-</otp:PartnerID>
     </otp:RequestedPartner>
  </otp:ProductRequestIn>

WSDL 文件 returns 1 个函数称为 ProductRequest。

我尝试了很多建议,目前 none 其中的建议有效。我不确定我是否应该在函数 ProductRequest 中使用 XML 和 XML are 参数(没有用)或者我应该建立一些数组并将其解析为参数(没有工作,或者没有正确完成)

WSDL 可以在这里找到:http://uddi.onetrail.net/uddidocs/ICT_PROD/Deployment/ProductRequest/ProductRequest.wsdl

尝试使用 xml 的结构准备 php 数组,然后:

<?php
$client = new \SoapClient($wsdl, [
        'trace' => true, 
        'style' => SOAP_DOCUMENT, 
        'use' => SOAP_LITERAL, 
        'exceptions' => true
        ]);
 $params = [
     'fromRole' => [
         'PartnerRoleDescription' => [
             'ContactInformation' => [
                 'contactName' => '?', 
                 'EmailAddress' => '?',
                 'telephoneNumber' => [
                     'CommunicationsNumber' => '?',
                 ]
              ],
              'GlobalPartnerRoleClassificationCode' => '?',
              'PartnerDescription' => [
                  'BusinessDescription' => [
                  ]
              ],
              'GlobalPartnerClassificationCode' => '?',
          ] 
      ],
      'Authentication' => [
          'Username' => 'USERNAME',
          'Password' => 'PASSWORD',
      ],
      'productIdentifier' => '---',
      'lang' => 'NL',
      'ProductInformationType' => 'RIC',
      'RequestedPartner' => [
          'PartnerID' => 'PARTNERID',
      ]
 ];

 $result = $client->__soapCall('Your SOAP method', [$params]);

还有另一种方式(但比较丑)用curl调用SOAP。您必须在 $xmlString 变量中创建包含 XML 的字符串。例如:

<?php
$headers = array(
    "Content-Type: application/soap+xml; charset=utf-8",
    "Content-Length: ".strlen($xmlString)
    ); 


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $soapUrl);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlString);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    try {
        $response = curl_exec($ch);
    } catch (\Exception $e) {

        echo $e->getMessage();
    }

    curl_close($ch);

    $response = str_replace("soap:", "", $response);

    $xml = simplexml_load_string($response, 'SimpleXMLElement');