我有一个看起来像这样的Dataobject
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;
}
}
和服务操作如
public string pricinginput(pricinginput sourceValue)
{
return string.Format("You entered: {0}", 2323);
}
拨打我必须做的服务
<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,我的datacontext已经将数据元素定义为input1的属性,inptu2 ...
<pricinginput>
<sourcevalue>
<request input1="" input2="" input3=""/>
<sourcevalue>
</pricinginput>
答案 0 :(得分:0)
这个怎么样:您可以自己开发一个序列化程序,然后将该对象序列化为您自定义的xml格式?