在SoapHeader类中传递身份验证凭据

时间:2016-06-29 09:40:19

标签: php soap wsdl soap-client soapheader

我有一个xml文件,格式如下

viewDidLayoutSubviews

给出以下SOAP标头

<?php

$xmlstr = <<<XML
<?xml version="1.0" encoding="UTF-8" ?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:tusa="http://schemas.datacontract.org/2004/07/Tusa.Services.ConsumerConnect" xmlns:tem="http://tempuri.org/">
<soap:Header>
    <AuthenticationCredentials>
    <tusa:Password>XXXXX</tusa:Password>
    <tusa:Username>XXXXX</tusa:Username>
    </AuthenticationCredentials>
</soap:Header>
<soap:Body>
    <tem:AddProduct>
        <tem:CustomerDetail>
                <tusa:AddressLine1>52 TEST DRIVE</tusa:AddressLine1>
                <tusa:City>JOHANNESBURG</tusa:City>
                <tusa:MaritalStatus>Unknown</tusa:MaritalStatus>
                //more nodes
        </tem:CustomerDetail>
    </tem:AddProduct>
</soap:Body>
</soap:Envelope>
XML;

如何将用户名和密码传递给SoapHeader类。我尝试过使用下面的代码但是我收到了错误

  

验证凭据是必需的

<soap:Header>
    <AuthenticationCredentials>
    <tusa:Password>XXXXX</tusa:Password>
    <tusa:Username>XXXXX</tusa:Username>
    </AuthenticationCredentials>
</soap:Header>

1 个答案:

答案 0 :(得分:1)

我认为你正在寻找类似的东西

[0]