我的目标是SOAP请求,如下所示,
<S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope">
<S:Header>
<a:Action xmlns:a="http://www.w3.org/2005/08/addressing" S:mustUnderstand="1">http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue</a:Action>
<a:MessageID xmlns:a="http://www.w3.org/2005/08/addressing">uuid-696c51d8-4866-4ff4-9f8b-24f1ad8ca438</a:MessageID>
<a:ReplyTo xmlns:a="http://www.w3.org/2005/08/addressing">
<a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
</a:ReplyTo>
<a:To xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="_1" S:mustUnderstand="1">https://thirdparty.authentication.business.gov.au/R3.0/vanguard/S007v1.2/service.svc</a:To>
</S:Header>
<S:Body>
....
</S:Body>
</S:Envelope>
到目前为止,我已经找到了标题,
const ACTION_ISSUE = 'http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue';
const NS_ADDR = 'http://www.w3.org/2005/08/addressing';
$message_id = uniqid('uuid-');
$action = new SoapHeader(NS_ADDR, 'Action', ACTION_ISSUE, true);
$message_id = new SoapHeader(NS_ADDR, 'MessageID', $message_id);
$reply_to_addr = array(
'Address' => new SoapVar('http://www.w3.org/2005/08/addressing/anonymous', XSD_STRING, null, null, null, NS_ADDR),
);
$address_val = new SoapVar($reply_to_addr, SOAP_ENC_OBJECT, null, null, null, NS_ADDR);
$reply_to = new SoapHeader(NS_ADDR, 'ReplyTo', $address_val);
$to = new SoapHeader(NS_ADDR, 'To', 'https://thirdparty.authentication.business.gov.au/R3.0/vanguard/S007v1.2/service.svc', true);
但问题是我根本无法弄清楚如何将命名空间属性注入SOAP标头