在消息上指定的SOAP操作''与HTTP SOAP Action,'Logon'不匹配

时间:2015-07-02 09:33:46

标签: web-services soap header envelope c++builder-xe

对于较旧的项目,我需要与soap服务器通信。 该项目是在Embarcadero C ++ Builder XE中创建的。 我通过wizzard生成了一个界面,看起来很好。

函数调用给出了上面的错误,我已经发现缺少SOAP头。 这是因为我在Visual Studio C#中构建了一个工作客户端。 我查看了肥皂信封,看到C#版本有一个带有动作的Header块。 C ++封套中缺少此部分。 我已经设法添加标题,但我无法添加“操作”。

有什么建议吗?

这是调用服务的部分

UnicodeString uri = "https://webservice.soap.com/v01/authentication.svc";
UnicodeString org = "myorg";
UnicodeString usr = "user1";
UnicodeString pas = "pass1";

Soaphttpclient::THTTPRIO* rio = new Soaphttpclient::THTTPRIO(0);
rio->OnBeforeExecute = HTTPRIO1BeforeExecute;
rio->OnAfterExecute = HTTPRIO1AfterExecute;

_di_Authenticate client = GetAuthentication(false, uri, rio);
Identity2 *id = client->Logon(org, usr, pas);

生成的肥皂标题

[ C++ Soap-Env-SENT ]

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Body>
        <Logon xmlns="http://justanexampleserver.LogonRequest">
            <Organisatie xmlns="">myorg</Organisatie>
            <Useraccount xmlns="">user1</Useraccount>
            <Usercredentials xmlns="">pass1</Usercredentials>
        </Logon>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

[ C++ Soap-Env-RECEIVED ]

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/fault</a:Action>
    </s:Header>
    <s:Body>
        <s:Fault>
            <s:Code>
                <s:Value>s:Sender</s:Value>
                <s:Subcode>
                    <s:Value>a:ActionMismatch</s:Value>
                </s:Subcode>
            </s:Code>
            <s:Reason>
                <s:Text xml:lang="en-US">The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'Logon'. </s:Text>
            </s:Reason>
            <s:Detail>
                <a:ProblemHeaderQName>a:Action</a:ProblemHeaderQName>
            </s:Detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

以下是C#为我生成的Soap标头

[ C# Soap-Env-SENT ]

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope">
  <s:Header>
    <a:Action s:mustUnderstand="1">Logon</a:Action>
    <a:MessageID>urn:uuid:08d93e64-7104-4bcd-90ed-5bdf613d6631</a:MessageID>
    <a:ReplyTo>
      <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
    </a:ReplyTo>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Logon xmlns="http://justanexampleserver.LogonRequest">
      <Organisatie xmlns="">myorg</Organisatie>
      <Useraccount xmlns="">user1</Useraccount>
      <Usercredentials xmlns="">pass1</Usercredentials>
    </Logon>
  </s:Body>
</s:Envelope>

[ C# Soap-Env-RECEIVED ]
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
  <s:Header>
    <a:Action s:mustUnderstand="1">LogonResponse</a:Action>
    <a:MessageID>urn:uuid:af0d6163-afbb-48cb-aa7b-e9b0042a61c4</a:MessageID>
    <a:RelatesTo>urn:uuid:08d93e64-7104-4bcd-90ed-5bdf613d6631</a:RelatesTo>
  </s:Header>
  <s:Body>
    <ns0:AuthenticationData xmlns:ns0="http://justanexampleserver.AuthenticationData">
  <Identity>
    <Securitytoken>4be6a5d8-aa6b-47cd-8e75-20506f138134</Securitytoken>
  </Identity>
</ns0:AuthenticationData>
  </s:Body>
</s:Envelope>

将C ++代码更改为此后,我可以看到标题。 但我不知道如何添加动作“登录”

UnicodeString uri = "https://webservice.soap.com/v01/authentication.svc";
UnicodeString org = "myorg";
UnicodeString usr = "user1";
UnicodeString pas = "pass1";

Soaphttpclient::THTTPRIO* rio = new Soaphttpclient::THTTPRIO(0);
rio->OnBeforeExecute = HTTPRIO1BeforeExecute;
rio->OnAfterExecute = HTTPRIO1AfterExecute;

TSOAPHeader *hdr = new TSOAPHeader();
hdr->MustUnderstand = true;
rio->SOAPHeaders->Send(hdr);

_di_Authenticatie client = GetAuthentication(false, uri, rio);
Identity2 *id = client->Logon(org, usr, pas);

此更改为我提供了以下标题......但仍然错误: - (

[ C++ Soap-Env-SENT ]

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header>
        <NS1:TSOAPHeader xmlns:NS1="urn:InvokeRegistry" SOAP-ENV:mustUnderstand="1"/>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <Logon xmlns="http://justanexampleserver.LogonRequest">
            <Organisatie xmlns="">myorg</Organisatie>
            <Useraccount xmlns="">user1</Useraccount>
            <Usercredentials xmlns="">pass1</Usercredentials>
        </Logon>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

[ C++ Soap-Env-RECEIVED ]

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
    <s:Header>
        <a:Action s:mustUnderstand="1">http://www.w3.org/2005/08/addressing/fault</a:Action>
    </s:Header>
    <s:Body>
        <s:Fault>
            <s:Code>
                <s:Value>s:Sender</s:Value>
                <s:Subcode>
                    <s:Value>a:ActionMismatch</s:Value>
                </s:Subcode>
            </s:Code>
            <s:Reason>
                <s:Text xml:lang="en-US">The SOAP action specified on the message, '', does not match the HTTP SOAP Action, 'Logon'. </s:Text>
            </s:Reason>
            <s:Detail>
                <a:ProblemHeaderQName>a:Action</a:ProblemHeaderQName>
            </s:Detail>
        </s:Fault>
    </s:Body>
</s:Envelope>

0 个答案:

没有答案