提问人:Sergei 提问时间:1/9/2023 更新时间:1/9/2023 访问量:81
PHP 中的 SOAP 请求和响应
SOAP request and response in PHP
问:
我对这个问题绝对是新手。我需要从PHP中的SOAP请求中获取令牌。
请求
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header/>
<soap:Body>
<tem:GetToken>
<tem:WebChanelID>8</tem:WebChanelID>
<tem:AccessCode>444555</tem:AccessCode>
</tem:GetToken>
</soap:Body>
</soap:Envelope>
答:
0赞
Sergei
1/9/2023
#1
我在这里做错了什么?
$soapUrl = "https://hma.ecvi.ru/service/webform.wsdl.php";
$xml_post_string = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tem="http://tempuri.org/">
<soap:Header/>
<soap:Body>
<tem:GetToken>
<tem:WebChanelID>631</tem:WebChanelID>
<tem:AccessCode>989</tem:AccessCode>
</tem:GetToken>
</soap:Body>
</soap:Envelope>';
$headers = array(
"POST /package/package_1.3/packageservices.asmx HTTP/1.1",
"Host: hma.ecvi.ru",
"Content-Type: application/soap+xml; charset=utf-8",
"Content-Length: ".strlen($xml_post_string)
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$response1 = str_replace("<soap:Body>","",$response);
$response2 = str_replace("</soap:Body>","",$response1);
$parser = simplexml_load_string($response2);
echo $parser;
评论
0赞
Martin54
1/9/2023
您需要更新您的问题。没有人会检查你的答案。
评论