Solved

Weird Web Services App

Posted on 2006-11-08
11
309 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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