2
我有一个数据类型,我在WCF中用于发送SOAP响应。它看起来像这样:命名空间不附加到WCF中的bool,除非与类的命名空间不同
<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">
<start-call-recording-response xmlns="http://foobar">
<response>true</response>
</start-call-recording-response>
</s:Body>
</s:Envelope>
的问题是,在命名空间(http://foobar
)未在元素出现。也就是说,除非将XmlElementAttibute的命名空间更改为与父类的XmlRootAttribute命名空间不同的内容。下面是启动呼叫录音的响应类:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.18033")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(TypeName = "StartcallrecordingresponseType")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://foobar", ElementName = "start-call-recording-responseType")]
public partial class StartcallrecordingresponseType
{
[System.ServiceModel.MessageBodyMemberAttribute(Namespace = "http://foobar")]
private bool responseField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "http://foobar", ElementName = "response", IsNullable = false)]
public bool Response
{
get
{
return this.responseField;
}
set
{
this.responseField = value;
}
}
}
如果我改变上述响应比包含类的命名空间的东西XmlElementAttribute的命名空间,它会出现在SOAP信封的。如果它们相同,则不会出现。尝试了XmlTypeAttributes,XmlRootAttributes和XmlElementAttributes的许多变体。
这很有道理。谢谢! – ColonelGibberish 2013-03-23 18:04:51
那你能接受答案吗? – flup 2013-03-23 20:26:30
已接受。谢谢。 – ColonelGibberish 2013-04-03 19:47:28