How to keep whitespace when invoke web service with SOAP method

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<table>
<tbody>
<tr>
<td>
<span class="x_vote-count-post 0 <a title="This question does not show any research effort; it is unclear or not useful (click again to undo)
down vote http://stackoverflow.com/questions/11844841/how-to-keep-whitespace-when-invoke-web-service-with-soap-method#" title="This is a favorite question (click again to undo)
favorite
</td>
<td>


I have a web service written by C#, assume that is http://www.mysvr.com/answer/sms.asmx
http://www.mysvr.com/answer/sms.asmx . This service has a operations named "Hello", one variable named "cnt1", and I will transfer value to this variable.
If I use XML to read it, like:
<pre class="lang-cs prettyprint
Code:
<span class="typ XmlDocument<span class="pln  xdoc <span class="pun =<span class="pln  <span class="kwd new<span class="pln  <span class="typ XmlDocument<span class="pun ();<span class="pln <br/><br/>xdoc<span class="pun .<span class="typ Load<span class="pun (<span class="str "http://www.mysvr.com/answer/sms.asmx/Hello?cnt1=abc"<span class="pun );<span class="pln <br/><br/><span class="kwd return<span class="pln  xdoc<span class="pun .<span class="typ ChildNodes<span class="pun [<span class="lit 1<span class="pun ].<span class="typ InnerXml<span class="pun ;
[/code]
I will get string "Hello everybody". There are 5 whitespaces between "Hello" and "everybody". I want to keep this whitespace.
But when I use SOAP to read it, like:
<pre class="lang-cs prettyprint
Code:
<span class="pun [<span class="typ System<span class="pun .<span class="typ Web<span class="pun .<span class="typ Services<span class="pun .<span class="typ Protocols<span class="pun .<span class="typ SoapDocumentMethodAttribute<span class="pun (<span class="str "http://tempuri.org/Hello"<span class="pun ,<span class="typ RequestNamespace<span class="pun =<span class="str "http://tempuri.org/"<span class="pun ,<span class="typ ResponseNamespace<span class="pun =<span class="str "http://tempuri.org/"<span class="pun ,<span class="typ Use<span class="pun =<span class="typ System<span class="pun .<span class="typ Web<span class="pun .<span class="typ Services<span class="pun .<span class="typ Description<span class="pun .<span class="typ SoapBindingUse<span class="pun .<span class="typ Literal<span class="pun ,<span class="typ ParameterStyle<span class="pun =<span class="typ System<span class="pun .<span class="typ Web<span class="pun .<span class="typ Services<span class="pun .<span class="typ Protocols<span class="pun .<span class="typ SoapParameterStyle<span class="pun .<span class="typ Wrapped<span class="pun )]<span class="pln <br/><span class="kwd public<span class="pln  <span class="kwd string<span class="pln  <span class="typ Hello<span class="pun (<span class="kwd string<span class="pln  cnt1<span class="pun )<span class="pln <br/><span class="pun {<span class="pln <br/>     <span class="kwd object<span class="pun []<span class="pln  results <span class="pun =<span class="pln  <span class="kwd this<span class="pun .<span class="typ Invoke<span class="pun (<span class="str "Hello"<span class="pun ,<span class="pln  <span class="kwd new<span class="pln  <span class="kwd object<span class="pun []<span class="pln  <span class="pun {<span class="pln cnt<span class="pun });<span class="pln <br/>     <span class="kwd return<span class="pln  <span class="pun ((<span class="kwd string<span class="pun )(<span class="pln results<span class="pun [<span class="lit 0<span class="pun ]));<span class="pln             <br/><span class="pun }<span class="pln <br/>
[/code]
I will get string "Hello everybody". There is only one whitespace between "Hello" and "everybody".
Problem: I want to use SOAP to call web service, and I want to keep 5 white space between "Hello" and "everybody".
Any one can help me to solve this problem? May I have to re-code web service, or add argument to SOAP to enable to read 5 white space?

Thanks many.


</td>
</tr>
</tbody>
</table>

View the full article
 
Back
Top