Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET SOAP服务-添加额外信息_C#_Asp.net_Web Services_Soap - Fatal编程技术网

C# ASP.NET SOAP服务-添加额外信息

C# ASP.NET SOAP服务-添加额外信息,c#,asp.net,web-services,soap,C#,Asp.net,Web Services,Soap,我创建了一个简单的Web服务来接收数据,但是我缺少了一个元素,它来自客户端的SOAP示例,我似乎无法模拟 下面是带有示例SOAP布局的Web服务: [WebMethod] public void ReceiveStatusUpdate(string Reference, string ThirdPartyReference, string Status) { } <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xml

我创建了一个简单的Web服务来接收数据,但是我缺少了一个元素,它来自客户端的SOAP示例,我似乎无法模拟

下面是带有示例SOAP布局的Web服务:

[WebMethod]
public void ReceiveStatusUpdate(string Reference, string ThirdPartyReference, string Status)
{
}

<?xml version="1.0" encoding="utf-8"?>
<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:Body>
            <ReceiveStatusUpdate xmlns="http://tempuri.org/">
                <Reference>string</Reference>
                <ThirdPartyReference>string</ThirdPartyReference>
                <Status>string</Status>
            </ReceiveStatusUpdate>
    </soap:Body>
</soap:Envelope>

有人能解释一下我需要添加什么吗:-)

上面“您的”示例中的xmlns:soap名称空间似乎丢失了。它的值应始终为:“”


命名空间将信封定义为SOAP信封,如果使用不同的命名空间,通常情况下,消费应用程序会生成错误并丢弃消息。

要解决缺少的元素,我需要在服务中声明一个对象,然后将每个字符串声明为对象中的变量,请参阅下面的代码:

namespace WebApplication1
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class Update : WebService
    {
        [WebMethod]
        public void ReceiveStatusUpdate(Object StatusUpdate)
        {
            var reference = StatusUpdate.Reference;
            var thirdPartyReference = StatusUpdate.ThirdPartyReference;
            var status = StatusUpdate.Status;
        }

        public class Object
        {
            public string Reference;
            public string ThirdPartyReference;
            public string Status;
        }
    }
}
我希望这对其他人有用:-)

namespace WebApplication1
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class Update : WebService
    {
        [WebMethod]
        public void ReceiveStatusUpdate(Object StatusUpdate)
        {
            var reference = StatusUpdate.Reference;
            var thirdPartyReference = StatusUpdate.ThirdPartyReference;
            var status = StatusUpdate.Status;
        }

        public class Object
        {
            public string Reference;
            public string ThirdPartyReference;
            public string Status;
        }
    }
}