2015-02-04 5 views
1

저는 잠시 동안 문제에 봉착했습니다. 나는 PHP에서 일하기, SOAP UI에서 작동이 요청을 얻으려고 :. 이 응답을 어떻게 검색합니까?

<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 파일은 ProductRequest라고 한 기능을 반환합니다.

나는 많은 제안을 시도했지만 지금까지 아무도 시도하지 않았다. XML을 사용하여 XML을 paramter (작동하지 않음)로 사용해야하는지 또는 일부 배열을 작성하여 인수로 파싱해야하는지 (작동하지 않거나 올바르게 수행하지 못했습니다.)

은 WSDL은 여기에서 찾을 수 있습니다 : http://uddi.onetrail.net/uddidocs/ICT_PROD/Deployment/ProductRequest/ProductRequest.wsdl

답변

1

다음 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]); 

또한 컬과 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'); 
+0

응답 해 주셔서 감사합니다. 아직 작동하지 않습니다 (일부 위치를 변경해야만 함) 오류가 발생합니다. Uncaught SoapFault 예외 : [soap : Server] ProductRequest의 오류 SoapClient :: __ getFunctions()는 다음을 반복합니다. ProductCatalogType ProductRequest (ProductRequestIn $ parameters) ProductRequestIn 구조체가 유효하지 않다는 의미입니까? – Hawiak

+0

SOAP 호출은 무엇입니까 ?? $ result = $ client -> __ soapCall ('ProductRequest', [$ params]); ?? 어쩌면 당신은 'ProductRequestIn'=> [ – tomcyr

+0

으로 $ params에 root를 추가해야합니다. 예, ProductRequest는 제가 호출하려고하는 메소드입니다. 코드를 실행할 때 5-10 초가 걸리고이 오류가 표시됩니다. ProductRequestIn에 배치하는 것은 효과가없는 것 같습니다. – Hawiak

관련 문제