缺少 UsernameToken 元素

发布于 2024-09-10 02:28:36 字数 1146 浏览 2 评论 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 元素完全丢失。

I am getting a request in the following method but the soap message does not appear to contain the UsernameToken Element:

$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();

The request that is produced looks like this:

<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>

You'll notice that the UsernameToken element is completely missing.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那些过往 2024-09-17 02:28:36

这个怎么样..向 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();

how about this.. added 'security' to 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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文