C# 将数据传输对象转换为XmlElement
我有一个像这样的数据对象C# 将数据传输对象转换为XmlElement,c#,.net,asp.net,wcf,web-services,C#,.net,Asp.net,Wcf,Web Services,我有一个像这样的数据对象 namespace WCFDemo { /// <remarks/> [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.Compo
namespace WCFDemo
{
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class pricinginput
{
/// <remarks/>
public aRequest request;
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class aRequest
{
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string input1;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string input2;
/// <remarks/>
[System.Xml.Serialization.XmlAttributeAttribute()]
public string input3;
}
}
我要打电话给服务部
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://Server/Service" xmlns:wcf="http://schemas.datacontract.org/2004/07/WCFDemo">
<soapenv:Header/>
<soapenv:Body>
<ser:pricinginput>
<!--Optional:-->
<ser:sourceValue>
<wcf:request>
<wcf:input1>?</wcf:input1>
<wcf:input2>?</wcf:input2>
<wcf:input3>?</wcf:input3>
</wcf:request>
</ser:sourceValue>
</ser:pricinginput>
</soapenv:Body>
</soapenv:Envelope>
?
?
?
如何将sourcevalue转换为类似belwo的xmlelemet,my datacontext已经将数据元素定义为input1、Input2的属性
<pricinginput>
<sourcevalue>
<request input1="" input2="" input3=""/>
<sourcevalue>
</pricinginput>
这样如何:您可以自己开发一个序列化程序,然后将对象序列化为自定义的xml格式?您的上下文和目标是什么?对SOAP服务使用SOAP消息有什么不对?我需要以给定的格式提取消息并将其发布到不同的服务。
<pricinginput>
<sourcevalue>
<request input1="" input2="" input3=""/>
<sourcevalue>
</pricinginput>