.NET Webservice replace tags with < >

I'm trying to use someone's web service that takes a string parameter UserIDs (all wsdl so far) But UserIDs is is really a mini xml in itself <users><user>A</user><user>b</user></users>. I made a string like that and sent thru web service and it returned failure. I did a trace on it and found out .NET webservice changes all the tags < and > to &lt; and &gt;

Is there anyway to preserve < and > as they are without having to modify the web reference into a complex type mannually?
gotdoughAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

diablocuteCommented:
You can turn URL Encoding off
0
OliWarnerCommented:
If you dont want something converted dont pass it into the replacer...

Otherwise make your own service to replace a custom tag like []s or something like that with <>s after the above has finished...
0
gotdoughAuthor Commented:
Hmm I never heard of url encoding option or replacer under soap. It seems to me I import web reference and I call the functions specified by wsdl.

my code is basically
Dim MyService = new XYZWebService
userList = "<users><user>A</user><user>b</user></users>"
MyService.SendUsers(userList)

Whoever makes it work for me is greatly appreciated
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

OliWarnerCommented:
assuming the funtion retuns instead of response outputting:

dim MyService as XYZWebService = new XYZWebService
dim userList as String = "<users><user>A</user><user>b</user></users>"
dim outList as String = MyService.SendUsers(userList)

Damnit I hate VB.net Give me classic ASP or C# anyday...
0
OliWarnerCommented:
and then:
Response.Write(outList)
0
OliWarnerCommented:
scrub that post... here we go...

dim MyService as XYZWebService = new XYZWebService
dim userList as String = "<users><user>A</user><user>b</user></users>"
dim outList as String = MyService.SendUsers(userList)

outList  = Replace(outList, "&lt;users&gt;", "<users>")
outList  = Replace(outList, "&lt;user&gt;", "<user>")
outList  = Replace(outList, "&lt;/users&gt;", "</users>")
outList  = Replace(outList, "&lt;/user&gt;", "</user>")

Response.Write(outList)
0
gotdoughAuthor Commented:
I think there is a misconception here and I apologize for it. This is not ASP so there is no response object. I'm only writing the client connectivity as a windows application. And feel free to use C# :)

I guess this code is more intuitive

Sub Form_Load handles Form1.OnLoad()
  Dim MyService = new XYZWebService
  XYZWebService.URL = "http://www.xyz.com/getdough.asmx"
  userList = "<users><user>A</user><user>b</user></users>"
  'This line returns fail because server could not interpret &lt;users&gt;&lt;user...
  MsgBox MyService.SendUsers(userList)
End Sub


0
gotdoughAuthor Commented:
Okay again I think what I'm trying to do is not send any &lt; and &gt; out in the first place. I don't care about formatting the response I get back as long as it doesn't generate an error.
0
OliWarnerCommented:
Oh I think I see what's going on here...
Any & sysbmols invalidate XML... Its hard to guess not knowing what this mystery service actually does...

http://www.xyz.com/getdough.asmx
Sub Form_Load handles Form1.OnLoad()
  Dim MyService = new XYZWebService
  XYZWebService.URL = "http://www.xyz.com/getdough.asmx"
  userList = "<users><user>A</user><user>b</user></users>"
  MsgBox MyService.SendUsers(Replace(Replace(userList ,"&lt;","<"),"&gt;",">"))
End Sub

That's pretty fugly...

If that still doesnt work you've got something URLEncoding your urls automatically which needs to be turned off.
Either that or you need to modify this webservice to swap &lt; and &gt; back to proper characters...

I apologise or so many bodged attempts but its 6:50am here and I'm still yet to get some sleepage...
0
gotdoughAuthor Commented:
Let's not get too far off, all I'm trying to figure out is

I'm trying to send:
MyService.SendUsers("<users><user>A</user><user>b</user></users>")

Trace shows
<SendUsers>
<UserList>&lt;users&gt;&lt;user&gt;A&lt;/user&gt;&lt;user&gt;&lt;/user&gt;&lt;/users&gt;</UserList>
</Sendusers>

I want the trace to show
<SendUsers>
<UserList><users><user>A</user><user>b</user></users><UserList>
</Sendusers>

Without having to modify anything on the webservice end or web reference
0
diablocuteCommented:
I don't know what MyService is a type of

but HttpRequest does have a property for URL Encoding

HttpRequest.ContentType = "application/x-www-form-urlencoded";
or "text/html"

Try to find the one you are looking for.

The problem you are having is called URL Encoding
0
diablocuteCommented:
sorry, didn't read that it was a webservice

There is a property called myService.RequestEncoding
0
diablocuteCommented:
OliWarner: I really dislike when people post links that they google and it's the first one they see, without ever reading how relavent it is to the question

Back to the typic

gotdough, I think you should try this

myService.RequestEncoding = "text/xml";

Based on that, myService object will take the input as text and pass it on.
0
OliWarnerCommented:
diablocute that's the MSDN page on services using RequestEncoding.
Its explains how to use it in different languages and what the returns will be.

Yout assumptions on whether it will work are based on the webservice actually inheriting the command from the WebClientProtocol class as the page I posted explains. If it doesnt do that its a rubbished suggestion.

I really dislike when people care more about the points that fixing an issue. Chill down, I'm only explaining things.
0
diablocuteCommented:
I did some more research,

"text/html" might work also
0
gotdoughAuthor Commented:
Thanks for the suggest guys. Unfortunately RequestEncoding is some enumerate type and I think it only specify the character encoding while this problem is with XML serialization. I just figure out this encoding is called ISO 8859-1 that changes HTML/XML characters into ampersand symbols.
0
moduloCommented:
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.