Solved

Weird Web Services App

Posted on 2006-11-08
11
319 Views
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.
0
Comment
Question by:ed124
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17900271
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.

Bob

0
 

Author Comment

by:ed124
ID: 17900317
1.1

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

Expert Comment

by:sdeen
ID: 17901040

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?
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:ed124
ID: 17901384
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())
myWriter.Write(xmlRequest)
myWriter.Close()

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

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

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


0
 
LVL 1

Expert Comment

by:sdeen
ID: 17901598
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.

0
 

Author Comment

by:ed124
ID: 17901794
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.
0
 
LVL 1

Accepted Solution

by:
sdeen earned 500 total points
ID: 17902062
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?
0
 

Author Comment

by:ed124
ID: 17902265
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
0
 
LVL 1

Expert Comment

by:sdeen
ID: 17902519
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.
0
 

Author Comment

by:ed124
ID: 17902551
Thanks anyway. Anyone else?
0
 

Author Comment

by:ed124
ID: 18012755
I went another direction on this, but the suggestion to use WFetch was a big help. So I'm giving sdeen the points.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question