Solved

Weird Web Services App

Posted on 2006-11-08
11
311 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
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.…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now