C# 使用SOAP方法调用web服务时如何保留空格

C# 使用SOAP方法调用web服务时如何保留空格,c#,soap,whitespace,C#,Soap,Whitespace,我有一个由C#编写的web服务,假设是这样。这个服务有一个名为“Hello”的操作,一个名为“cnt1”的变量,我将把值传递给这个变量 如果我使用XML来读取它,比如: XmlDocument xdoc = new XmlDocument(); xdoc.Load("http://www.mysvr.com/answer/sms.asmx/Hello?cnt1=abc"); return xdoc.ChildNodes[1].InnerXml; [System.Web.Services.P

我有一个由C#编写的web服务,假设是这样。这个服务有一个名为“Hello”的操作,一个名为“cnt1”的变量,我将把值传递给这个变量

如果我使用XML来读取它,比如:

XmlDocument xdoc = new XmlDocument();

xdoc.Load("http://www.mysvr.com/answer/sms.asmx/Hello?cnt1=abc");

return xdoc.ChildNodes[1].InnerXml;
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Hello",RequestNamespace="http://tempuri.org/",ResponseNamespace="http://tempuri.org/",Use=System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string Hello(string cnt1)
{
     object[] results = this.Invoke("Hello", new object[] {cnt});
     return ((string)(results[0]));            
}
我会得到字符串“大家好”。“Hello”和“Everyone”之间有5个空格。我想保留这个空白

但是当我用肥皂读它的时候,比如:

XmlDocument xdoc = new XmlDocument();

xdoc.Load("http://www.mysvr.com/answer/sms.asmx/Hello?cnt1=abc");

return xdoc.ChildNodes[1].InnerXml;
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/Hello",RequestNamespace="http://tempuri.org/",ResponseNamespace="http://tempuri.org/",Use=System.Web.Services.Description.SoapBindingUse.Literal,ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public string Hello(string cnt1)
{
     object[] results = this.Invoke("Hello", new object[] {cnt});
     return ((string)(results[0]));            
}
我将得到字符串“大家好”。“Hello”和“Everyone”之间只有一个空格

问题:我想使用SOAP调用web服务,我想在“Hello”和“Everyone”之间保留5个空格

有人能帮我解决这个问题吗?我是否必须重新编码web服务,或者向SOAP添加参数以允许读取5个空格

非常感谢。

尝试在字符串中包含“Hello Everyone”字符串。比如:

"
<![CDATA[
" "
]]>
"
<root>
    <welcome><![CDATA[Hello     everybody]]></welcome>
</root>