0

我收到以下方法的请求,但肥皂消息似乎不包含 UsernameToken 元素:

$policy = new WSPolicy(
    array(
        'useUsernameToken'=>true
    )
);
$security = new WSSecurityToken(
    array(
        'user'=>$username,
        'passwordType'=>'PlainText',
        'password'=>$password
    )
);
// create client in WSDL mode
$client = new WSClient(
    array (
        'wsdl'=>$service_wsdl,
        'to'=>$service_url,
        'policy'=>$policy,
        'securityToken'=>$security,
        'trace'=>1
    )
);
$proxy = $client->getProxy();
$proxy->Ping();

生成的请求如下所示:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header>
        <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1">
        </wsse:Security>
    </soapenv:Header>
    <soapenv:Body>
        <ns1:Ping xmlns:ns1="http://streamlinedsalestax.org/efile"/>
    </soapenv:Body>
</soapenv:Envelope>

您会注意到 UsernameToken 元素完全丢失了。

4

1 回答 1

0

这个怎么样..向WSPolicy添加了“安全性”

<?php
$policy = new WSPolicy(
    array('security' => array(
        'useUsernameToken'=>true
    ))
);
$security = new WSSecurityToken(
    array(
        'user'=>$username,
        'passwordType'=>'PlainText',
        'password'=>$password
    )
);
// create client in WSDL mode
$client = new WSClient(
    array (
        'wsdl'=>$service_wsdl,
        'to'=>$service_url,
        'policy'=>$policy,
        'securityToken'=>$security,
        'trace'=>1
    )
);
$proxy = $client->getProxy();
$proxy->Ping();
于 2010-07-19T01:23:59.090 回答