C# 为信封设置名称空间并在标记中使用此名称空间

C# 为信封设置名称空间并在标记中使用此名称空间,c#,xml,soap,C#,Xml,Soap,SOAP服务要求我发送这种格式的XML信封: <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://myNamespace.com"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

SOAP服务要求我发送这种格式的XML信封:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://myNamespace.com">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <typ:pushData>
            ...

...
但是我的客户发送了这样的信息:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <pushData xmlns="http://myNamespace.com">
            ...
pushDataResp = ServiceProxyProvider<IServiceBinding>.Invoke(Program.ServiceEndpoint, x => x.pushData(xxx, yyy));

[ServiceContract(Namespace = "http://myNamespace.com")]
public interface IServiceBinding
{
    [OperationContract]
    [FaultContract(typeof(ServiceException), Action = "", Name = "ServiceException")]
    [XmlSerializerFormat(SupportFaults = true)]
    int pushData(Xxx xxx, Yyy yyy);
}

...
我的客户端发送步骤如下所示:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <pushData xmlns="http://myNamespace.com">
            ...
pushDataResp = ServiceProxyProvider<IServiceBinding>.Invoke(Program.ServiceEndpoint, x => x.pushData(xxx, yyy));

[ServiceContract(Namespace = "http://myNamespace.com")]
public interface IServiceBinding
{
    [OperationContract]
    [FaultContract(typeof(ServiceException), Action = "", Name = "ServiceException")]
    [XmlSerializerFormat(SupportFaults = true)]
    int pushData(Xxx xxx, Yyy yyy);
}
pushDataResp=ServiceProxyProvider.Invoke(Program.ServiceEndpoint,x=>x.pushData(xxx,yyyy));
[ServiceContract(命名空间=”http://myNamespace.com")]
公共接口IServiceBinding
{
[经营合同]
[FaultContract(typeof(ServiceException),Action=”“,Name=“ServiceException”)]
[XmlSerializerFormat(SupportFaults=true)]
int pushData(Xxx-Xxx,Yyy-Yyy);
}

如何在我的C#代码中实现请求的格式?

这真的会给您带来问题吗?因为两者在语义上是等价的。在另一端,任何模糊不清的顺从都不应该看到任何区别。这就是我所想的。但第一个是可以接受的,第二个不是。