C#和#x2B;XML序列化
我有一个调用web服务的方法。调用此web服务时,将调用以下方法:C#和#x2B;XML序列化,c#,xml-serialization,C#,Xml Serialization,我有一个调用web服务的方法。调用此web服务时,将调用以下方法: [System.Web.Services.Protocols.SoapDocumentMethodAttribute( "http://mydomain.com/services/DoSomething", RequestNamespace = "http://mydomain.com/services", ResponseNamespace = "http://mydomain.com/servic
[System.Web.Services.Protocols.SoapDocumentMethodAttribute(
"http://mydomain.com/services/DoSomething",
RequestNamespace = "http://mydomain.com/services",
ResponseNamespace = "http://mydomain.com/services",
Use = System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("MyResponse")]
public MyResponse DoSomethingr(MyRequest myRequest)
{
object[] results = this.Invoke("DoSomething", new object[] { myRequest});
return ((MyResponse)(results[0]));
}
调用此方法时,我注意到XML包含以下内容:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<!-- XML --!>
</soap:Body>
</soap:Envelope>
我不会的。Soap是发布服务和访问远程数据的标准协议。没有它,远程服务器将无法理解您的请求。我不会。Soap是发布服务和访问远程数据的标准协议。如果没有它,远程服务器将无法理解您的请求。为什么要删除这些XML名称空间前缀??这些是用于调用web服务的SOAP标准的一部分-不要篡改它们,否则您的SOAP调用可能无法继续工作…如果您不需要包装器,请避免使用SoapDocumentMethodAttribute。如果您删除
内容,则不使用SOAP。如果您不想要soap web服务,最好使用WCF,一种不同的.NET编程模型。为什么要删除这些XML名称空间前缀??这些是用于调用web服务的SOAP标准的一部分-不要篡改它们,否则您的SOAP调用可能无法继续工作…如果您不需要包装器,请避免使用SoapDocumentMethodAttribute。如果您删除
内容,则不使用SOAP。如果您不想要soap web服务,最好使用WCF,一种不同的.NET编程模型。