0

我正在使用 C# .Net2 将肥皂消息传输到我的 Web 服务

肥皂信息是:

<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Header>
        <AUTHHEADER xmlns="http://mysite.com/WebServices/Agent">
            <AgentGUID>24563532-c973-fbf3-d072-d9cf671d5905</AgentGUID>
        </AUTHHEADER>
    </soap:Header>
    <soap:Body>
        <LoginRSA xmlns="http://mysite.com/WebServices/Agent">
            <loginId>admin@dt.com</loginId>
            <password>password</password>
            <tenant></tenant>
        </LoginRSA>
    </soap:Body>
</soap:Envelope>

在我的 C# 部分中,我定义了以下内容:

public class AuthHeader : SoapHeader
{
    public string AgentGUID;
}

[WebService(Namespace = "http://mysite.com/WebServices/Agent", Description = "Some description")]
public class AgentService : WebService
{
    public AuthHeader Authentication;

    [SoapHeader("Authentication")]
    [WebMethod(Description = "SomeDesc.", MessageName = "LoginRSA")]
    public LoginResult LoginRSA(string loginId, string password, string tenant)
    {
        if (Authentication != null)
        {
            string guid = Authentication.AgentGUID;
        }
    }
}

但我的身份验证始终为空,我无法读取标题,但我得到了soap:body 中的所有变量。

你能看出我的错误吗?谢谢。

4

0 回答 0