我们在Windows服务中托管了我们的WCF Web服务。我们正在使用basicHttpBinding。我们需要保持与Soap 1.1 Web服务的向后兼容性。我们的问题是缺少web方法参数中元素 EPTalkMessage 的命名空间。我搜索了很多,但我没有找到一些方法来为这个元素添加名称空间。
来自旧网络服务的肥皂是:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://aaa.sk/EPTalk/IssueDocument</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<IssueDocument xmlns="http://aaa.sk/EPTalk">
<EPTalkMessage xmlns="http://aaa.sk/EPTalk/ToSignInput" />
</IssueDocument>
</s:Body>
</s:Envelope>
新生成的肥皂是:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://aaa.sk/EPTalk/IssueDocument</Action>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<IssueDocument xmlns="http://aaa.sk/EPTalk">
<EPTalkMessage />
</IssueDocument >
</s:Body>
</s:Envelope>
服务签名如下:
[ServiceContract (Namespace = "http://aaa.sk/EPTalk")]
[XmlSerializerFormat(Use = OperationFormatUse.Literal, Style = OperationFormatStyle.Document)]
public interface IRegistryInputWebService
{
[OperationContract(Action = "http://aaa.sk/EPTalk/IssueDocument")]
RegistryServiceResult IssueDocument([MessageParameter(Name = "EPTalkMessage")]
UpvsPortalEmulator.ToSignInput.EPTalkMessage message);
}
结合:
BasicHttpBinding
{
MaxReceivedMessageSize = 1024 * 1024 * 10,
MaxBufferSize = 1024 * 1024 * 10,
ReaderQuotas =
{
MaxArrayLength = 1024 * 1024 * 10,
MaxStringContentLength = 1024 * 1024 * 10
},
MessageEncoding = WSMessageEncoding.Text,
Security = new BasicHttpSecurity
{
Mode = BasicHttpSecurityMode.None
}
};
已编辑:已添加EPTalkMessage定义。
[XmlType, XmlRoot (ElementName = "EPTalkMessage", Namespace = Declarations.SchemaVersion, IsNullable = false), Serializable]
public class EPTalkMessage
{
}
非常感谢你的帮助
答案 0 :(得分:0)
在搜索了一段时间后,我使用MessageContracts解决了这个问题。