PHP: Soap 通过 soap header 认证(non-wsdl 模式)
vim 配置

wos2 WSF/PHP soap header 认证实现

TLHL28 posted @ Thu, 16 Jun 2011 15:39:35 +0800 in 随笔 with tags PHP SOAP , 2565 readers

用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());
}

 

Rylan Landon said:
Tue, 01 Jan 2019 15:27:11 +0800

This is usually a superb posting, With thanks to get allowing people this review. Continue to keep writing. East Grinstead Accountants

Martin said:
Mon, 08 Jul 2019 23:17:34 +0800

In some cases, the hardest bit of the work is creating the right recommendation. We can do this for you. Despite whether you need just the hypothesis or the full paper behind it, we can do that. <a href="https://www.assignmentguarantee.co.uk/">Assignment Guarantee</a>

Martin said:
Mon, 08 Jul 2019 23:19:31 +0800

Much obliged to you for posting such an extraordinary article! I found your site ideal for my needs. It contains awesome and supportive posts. Keep doing awesome!. Much obliged to you for this magnificent Article!  [url=https://www.assignmentguarantee.co.uk/dissertation-editing]dissertation editing services UK[/url]

Martin said:
Mon, 08 Jul 2019 23:20:43 +0800

Much obliged to you for sharing such a conventional post.

buy dissertation online

 


Linker SEO said:
Thu, 06 Feb 2020 03:23:16 +0800

토메인은 토토사이트와 각종 웹툰사이트 현재 접속 가능한 최신 도메인들을 한곳에서 확인할 수 있습니다 나만의 토토도메인을 즐겨찾기를 통하여 알림 혜택도 받으세요! 토토

Linker SEO said:
Fri, 07 Feb 2020 03:35:23 +0800

Love is the emotion that makes the world go round. It’s love that makes the life ride worthwhile. Thus, when we find somebody whom we can love and who loves or might love us, we should never let that person go. But it’s not always easy to find true love. At times, it takes years and decades to wait for the ideal soulmate. However, you can stop such long waits and meet up with your true love fast. Love spells are just the thing you will need here. how to cast love spell

dfd said:
Thu, 13 Feb 2020 17:50:12 +0800

We offer end-to-end technical consultancy and know-how as well as know-why to broad spectrum of different requirements of the broadcasting industry.
broadcast consultancy
apple authorized service center in kolkata
apple reseller in guwahati
system Integration service providers
ipad air reseller in bhubaneswar
mac pro reseller in kolkata


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter