如何在Guzzle / Http中的SOAP信封中添加标头

问题描述

我目前有这个,如何在这个标题上添加标题?

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <testConnection xmlns="urn:http://url.com">
            <name>Test Connection</name>
        </testConnection>
    </Body>
</Envelope>

我尝试这样做

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Header>
        <Credentials>
            <username>USERNAME</username>
            <password>PASSWORD</password>
        </Credentials>
    </Header>
    <Body>
        <testConnection xmlns="urn:http://url.com">
            <name>Test Connection</name>
        </testConnection>
    </Body>
</Envelope>

仍然无效。有人知道如何在此标题上正确添加标题吗?

这是错误响应

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <faultcode xsi:type="xsd:string">ERROR</faultcode>
            <faultactor xsi:type="xsd:string"></faultactor>
            <faultstring xsi:type="xsd:string">1  Authentication failed! You need to send soap headers or HTTP headers containing your credentials. If you want to use soap headers,the credentials must have the form of &quot;&amp;lt;Credentials&amp;gt;&amp;lt;username&amp;gt;username&amp;lt;/username&amp;gt;&amp;lt;password&amp;gt;password&amp;lt;/password&amp;gt;&amp;lt;/Credentials&amp;gt; </faultstring>
            <detail xsi:type="xsd:string"></detail>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...