We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Weird Web Services App

ed124 asked
Medium Priority
Last Modified: 2012-05-05
I am working on a client application that is kind of strange, and I’m not sure how to pull this off. The client uses a web service that was developed by another party that I don’t have access to. There are already a number of clients that use this web service on their website. It’s a simple XML post to the service, with a response. What we are trying to accomplish is the XML to be posted to a service that I would create, do some processing on that XML string, then post the same XML string to the service that is already in use, pass its response back to my service, my service would then pass the response back to the client. The reason it has to be done this way is because we only want the clients to only have to change the URL they are posting to, and we cannot make any changes to the original web service.

I have implemented web services before, but I’ve never built one. So I’m not sure how to do this. I created simple “Hello Word” web service from a tutorial that works OK, but as soon as I post the XML string to it craps out. Any light you can shed would be great. I am doing this in ASP/VB.net in Visual Studio.
Watch Question

Most Valuable Expert 2012
Top Expert 2008

1) 2.0 or 1.1?

2) It sounds like you need to create a "wrapper" web service, that has an instance of another web service.

3) Web service proxies are a possibility.




Can you point me to some tutorials or samples of a wrapper web service?


What do you mean "it craps out"? Can you post any error info?

Does the same thing happen if you post simple text, instead of XML?


It errors out no matter what I post

I get: The remote server returned an error: (500) Internal Server Error.

*****Here is my test request:*****

Dim xmlRequest As String = "xmlRequest=<Request>Test</Request>"

Dim objRequest As HttpWebRequest = CType(WebRequest.Create("http://localhost/WebService1/Service1.asmx/Test/"), HttpWebRequest)
objRequest.Method = "POST"
objRequest.ContentLength = xmlRequest.Length
objRequest.ContentType = "application/x-www-form-urlencoded"

myWriter = New StreamWriter(objRequest.GetRequestStream())

Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse) <<< *****Errors out here*****
Dim sr As New StreamReader(objResponse.GetResponseStream())

*****Here is my Test service:*****

<WebMethod()> _
    Public Function Test(ByVal xml) As String
        Return xml
    End Function

You seem to be calling this service as a regular web request, instead of the proper way for invoking a service.

Assuming the service you're trying to access is working properly, the right way to call it is by adding a Web Reference to it in your project, and then you can instantiate it as you would any object.

Let's say the service you're trying to access has a class called XMLClass and a method called GetXMLResponse, and you named the web reference XMLWebService. Your code would then look something like this:

<WebMethod()> _
    Public Function Test(ByVal xml) As String  
        Dim XMLClass1 As  New XMLWebService.XMLClass
        String SomeText = XMLClass1.GetXMLResponse(xml)
        Return xml
    End Function

This is realy all you should need. Hope this helps.


The reason the request is like that is because many clients already are using the webservice, and most are requesting from classic asp. And like I said, all I want the clients to have to change is the URL they are posting to.

With the test code, all I was trying to do was pass an XML string, and have it respond with same XML. I also just had it to return “Hello World” and it did not work.
I see. I thought your code was to call the other (the original) web service.

I'd suggest using a tool such as WFetch to see what the exact error is from the web server. You can find it in the free IIS Resources pack from Microsoft.

Does it work when you test the asmx file in a web browser?

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


It works fine just invoking through the browser.

I just tried Wfetch, and I did get this error: 0x2745 (An established connection was aborted by the software in you host machine.): Socket Error on Recieve

Beats me then. I just tried your code (except in c#), and tested with WFetch and it works fine. As far as I can tell, the only problem in your code is you're passing a parameter called 'xmlRequest', and your method expects 'xml'. But I'm assuming that's just in your sample here.

Good luck. If you figure it out, post the solution.


Thanks anyway. Anyone else?


I went another direction on this, but the suggestion to use WFetch was a big help. So I'm giving sdeen the points.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.