用SwA模式上传附件, 下载的包里有相关实例。但是看产生的soap消息包不是SwA模式的, 依然是MTOM模式的.
$uri = "http://wsi.portalservice.dpf.huawei.com";
$key = "asdf";
$pwd = "asdf";
$time = date("mdhms");
$pwd = base64_encode(hash("SHA256",$key.$pwd.$time));
$url = "http://127.0.0.1:1234/Service";
$reqPayload = <<<XML
<ns1:AddRequest xmlns:ns1="http://localhost/namespace">
<albumId>1106011156080031</albumId>
<fileName>
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:content"></xop:Include>
</fileName>
</ns1:AddRequest>
XML;
$auth_data = array(
new WSHeader(array('name'=>'operatorId','data'=>$key)),
new WSHeader(array('name'=>'password','data'=>$pwd)),
new WSHeader(array('name'=>'timeStamp','data'=>$time)),
);
$header_options = array(
"ns"=>$uri,
'prefix'=>"ns1",
"name"=>"RequestSOAPHeader",
"data"=>$auth_data,
);
$header = new WSHeader($header_options);
$filePath = "/path/to/file/file.jpg";
$f = file_get_contents($filePath);
$msg = new WSMessage($reqPayload,
array(
'inputHeaders'=>array($header),
'attachments'=>array('content'=>$f),
'defaultAttachmentContentType'=>"image/jpeg",
)
);
$options = array(
'to'=>$url,
'useMTOM'=>"swa",
);
$api = new WSClient($options);
try {
$resMsg = $api->request($msg);
} catch (Exception $e) {
if ($e instanceof WSFault)
printf("Soap Fault: %s\n", $e->Reason);
else
printf("Message = %s\n", $e->getMessage());
}