我想连接到h1tps://ediwebs.sweatheranalysis.com.tr/sweatheranalysisediwebs.asmx?op = GetAnalysis并通过SoapClient或其他任何请求发送
POST /sweatheranalysisediwebs.asmx HTTP/1.1
Host: ediwebs.sweatheranalysis.com.tr
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<AuthHeader xmlns="http://sweatheranalysis.com.tr/ediwebs/">
<Partner>string</Partner>
<Password>string</Password>
</AuthHeader>
</soap12:Header>
<soap12:Body>
<GetAnalysis xmlns="http://sweatheranalysis.com.tr/ediwebs/" />
</soap12:Body>
</soap12:Envelope>
响应与此类似:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Header>
<AuthHeader xmlns="http://sweatheranalysis.com.tr/ediwebs/">
<Partner>string</Partner>
<Password>string</Password>
</AuthHeader>
</soap12:Header>
<soap12:Body>
<GetAnalysisResponse xmlns="http://sweatheranalysis.com.tr/ediwebs/">
<GetAnalysisResult>xml</GetAnalysisResult>
</GetAnalysisResponse>
</soap12:Body>
</soap12:Envelope>
我该怎么做?我已经尝试过了,但是我收到错误的无效登录信息。使用SOAPUI一切正常
try{
$username = 'username';
$password = 'password';
$soapURL = "https://ediwebs.sweatheranalysis.com.tr/sweatheranalysisediwebs.asmx?WSDL";
$client = new SoapClient($soapURL, [
'stream_context' => stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
]
])
]);
$auth = array(
'Partner' => $username,
'Password' => $password,
);
$header = new SoapHeader('http://sweatheranalysis.com.tr/ediwebs/','AuthHeader',$auth,'false');
$client->__setSoapHeaders($header);
$response = $client->__soapCall("GetAnalysis",$auth);
var_dump($response);
}catch(Exception $e){
echo $e->getMessage();
}
答案 0 :(得分:0)
将此行$header = new SoapHeader('http://sweatheranalysis.com.tr/ediwebs/', 'AuthHeader',$auth,'false');
更改为
$header = new SoapHeader('http://sweatheranalysis.com.tr/ediwebs/', 'AuthHeader',array('Partner' => 'username', 'Password' => 'password'),'false');
并工作