2016-12-09 7 views
0

にあるsoapUIを得ることができない、これは私が持っているものです。は私がSOAP接続に今時間苦労してきたし、それが仕事を得ることができないPHP関数

$url = 'https://xxx/connector.svc?singleWsdl'; 
$user = 'user'; 
$pass = 'pass'; 

$options = array(
     'uri'=>'http://schemas.xmlsoap.org/soap/envelope/', 
     'style'=>SOAP_RPC, 
     'use'=>SOAP_ENCODED, 
     'soap_version'=>SOAP_1, 
     'cache_wsdl'=>WSDL_CACHE_NONE, 
     'connection_timeout'=>15, 
     'trace'=>true, 
     'encoding'=>'UTF-8', 
     'exceptions'=>true, 
    ); 
try { 
    $soapclient = new SoapClient($url, $options); 
# $soapclient = new SoapClient($url); 
} 
catch(Exception $e) { 
    die($e->getMessage()); 
} 

私が試した「WDSL?」その後私が得る:

PHP Fatal error: SOAP-ERROR: Parsing WSDL: <message> 'IConnector_GetProduct_ServiceFaultFault_FaultMessage' already defined 

パラメータなしで要求が正常に動作します:

$result = $soapclient->GetVersionInfo(); 
$last_request = $soapclient->__getLastRequest(); 
$last_response = $soapclient->__getLastResponse(); 
print "Request: ".$last_request ."\n"; 
print "Response: ".$last_response."\n"; 
print_r($result); 

は結果:

Request: <?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="Unit4.AgressoWholesale.Connectors"><SOAP-ENV:Body><ns1:GetVersionInfo/></SOAP-ENV:Body></SOAP-ENV:Envelope> 

Response: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetVersionInfoResponse xmlns="Unit4.AgressoWholesale.Connectors"><GetVersionInfoResult xmlns:a="http://schemas.datacontract.org/2004/07/Unit4.AgressoWholesale.Common.Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:FullVersion>14.4.18.0</a:FullVersion><a:Release>14</a:Release><a:ServicePack>4</a:ServicePack><a:Fix>18</a:Fix><a:Version>0</a:Version><a:CustomCode/><a:AWBuild>38</a:AWBuild><a:AWFix>003</a:AWFix><a:AWCustomBuild/><a:AWCustomFix/><a:AWCustomCustomerCode/></GetVersionInfoResult></GetVersionInfoResponse></s:Body></s:Envelope> 
stdClass Object 
(
    [GetVersionInfoResult] => stdClass Object 
     (
      [FullVersion] => 14.4.18.0 
      [Release] => 14 
      [ServicePack] => 4 
      [Fix] => 18 
      [Version] => 0 
      [CustomCode] => 
      [AWBuild] => 38 
      [AWFix] => 003 
      [AWCustomBuild] => 
      [AWCustomFix] => 
      [AWCustomCustomerCode] => 
     ) 

) 

これまでのところは良いが、トラブルが... SOAPUIでは、それはで動作する必須である、ログインしようとして開始します:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:unit="Unit4.AgressoWholesale.Connectors" xmlns:unit1="http://schemas.datacontract.org/2004/07/Unit4.AgressoWholesale.Common.Contracts"> 
    <soapenv:Header/> 
    <soapenv:Body> 
     <unit:Login> 
     <unit:SecurityContext> 
      <unit1:SessionToken></unit1:SessionToken> 
      <unit1:UserId>user</unit1:UserId> 
      <unit1:Password>pass</unit1:Password> 
     </unit:SecurityContext> 
     </unit:Login> 
    </soapenv:Body> 
</soapenv:Envelope> 

しかし、PHPにこれを変換し、私はここに座礁しています...これは私が試したものです:

$data = array('SecurityContext' => array('SessionToken' => '' 
             ,'Password'  => $user 
             ,'UserId'  => $pass) 
          ); 
$data = array('SessionToken' => '' 
          ,'Password'  => $user 
          ,'UserId'  => $pass 
          ); 

$data = new stdClass; 
$data->SecurityContext = new stdClass; 
$data->SecurityContext->SessionToken = ''; 
$data->SecurityContext->UserId  = $pass; 
$data->SecurityContext->Password  = $user; 

#$result = $soapclient->__call('Login',array($data)); 
#$result = $soapclient->Login($data); 
$result = $soapclient->__soapCall('Login',array($data)); 

しかし、私がしようとするものに関係なく、パラメータまたは空の配列やはstdClassのないイベントを、私が取得:

PHP Fatal error: Uncaught SoapFault exception: [s:ServiceFault] An exception occurred 

それは私の狂気を運転している、私は致命的なexeptionについてのインターネット上の何かを見つけることができません '[s:ServiceFault]

私は間違って何をしていますか?どんな助けでも大歓迎です!

答えて

0

OK、問題を書き留めておけば、アンカーに行くことができます!

溶液を2倍であった:

1){}キャッチ試して使用することにより、より良いエラー報告を取得:

try { 
    $result = $soapclient->__call('Login',array($data)); 
    #$result = $soapclient->Login($data); 
    #$result = $soapclient->__soapCall('Login',array($data)); 
} catch (SoapFault $e) { 
    $error = $e->faultcode; 
    echo str_replace('>',">\n",$error) ; 
} 
$last_request = $soapclient->__getLastRequest(); 
$last_response= $soapclient->__getLastResponse(); 
print "\nRequest: " .str_replace('>',">\n",$last_request); 
print "\nResponse: ".str_replace('>',">\n",$last_response); 

私は私が必要なだけでlitleより多くの情報を持ってそのように!

2)それが動作

ユーザーフィールドにパスワードフィールドにパスワードとユーザー名を入力します。へ!仕事

  • コール作業を解析するすべての3つの方法(また、2つのコメントアウトもの、あなたが好きな1使用)の両方のアレイ構造と「新しいはstdClass」を使用して、それらの興味

    • については

  • 関連する問題