Debugging a web service


Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I working with a web service for the first time and I'm having trouble getting it to work. The web service was built by someone else, in java and the server is remote and I don't have access to the source to try to have it local.



I really need to see what the raw soap message being sent to the web service is. However, I can't figure out how to do this. Any ideas on how to do this?



Any other tricks/tips on building clients for web services would be appreciated (including how SF could be leveraged) would be appreciated.



Thanks!
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If you need to see the raw SOAP message, then you're best bet would be to create a quick little program that will read it and dump it to a file on disk.  Something like this:

Private Sub GetAndSaveResponse()
    Dim request As HttpWebRequest = DirectCast(WebRequest.Create("some url to the web service"), HttpWebRequest)
    Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)

    Dim input As Stream = response.GetResponseStream()
    Dim buffer As Byte(response.ContentLength - 1)
   
    input.Read(buffer, 0, response.ContentLength)

    File.WriteAllBytes("C:\output.txt", buffer)
End Sub

You'll of course, need to import System.IO and System.Net and I think that's all...

It's pretty quick and dirty, but it should get you a start Smile

StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
For some reason I remember that in VB, you can only put the dimensions on an array declaration on the variable name or the type... don't remember which one off hand, so the:

Dim buffer As Byte(response.ContentLength - 1)

might need to be:

Dim buffer(response.ContentLength - 1) As Byte

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks for the reply Ben.



Will this work with a proxy class? I.e. I'm using a proxy class to call the web service and I'd like to know what the SOAP message the proxy is generating is (because the darned thing ain't workin). The web service is somebody else's and is a java web service.



Thanks again!
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yes, when you create the HttpWebRequest object, you can set any of the properties you need before you make the call to GetResponse(), which is what actually sends the request and gets the response.  One of the properties you can set before sending the request is the Proxy property which accepts a System.Net.IProxy object... don't worry, though, there's already an implementation of that interface in the System.Net.WebProxy class.  Just create a new WebProxy object, give it the address, port, username, password, etc. for the proxy and set that object to the Proxy property on your HttpWebRequest object.  Now, if you want to see what the proxy is passing on to the web service, you'll have to set up a packet sniffer between the proxy and the web server, which could prove to be difficult.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Thanks Ben! I'll need to chew on this for a bit, but it is heading me in the correct direction I'm sure.
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Well, I've chewed and I'm choking... Crazy



Let me get this straight. I have a proxy class that will end up generating a soap message (which is just a plain text, xml string) and the only way I can see what is being generated is by setting up a proxy class and using a bloody port sniffer? They couldn't just have an option to show the bloody message? #@#%^#@



Somebody at MS needs to be shot!



OK, enough of the rant. Is this really the only way to see what is being sent? (I realize this might be easy to you, but I know next to nothing about port sniffers and proxies...so I'm looking at another bloody steep hill to climb...sigh...starting to rant again). I'm getting a bad header and need to know what I'm doing wrong.



Thanks!
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Is this really the only way to see what is being sent?

LOL....I understand.  Really if you want to get a true view of what is going on, then the port sniffer is the best way to go. We have learned all sorts of junk through the port sniffers BigGrin

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Sigh....OK, I'll bite the bullet and learn to sniff...Pinch
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I so totally don't get this, at almost every level Blink



I d/l a tool called tcpTrace. It was recommened for just this sort of thing. See this article, the second tip.



http://www.ondotnet.com/pub/a/dotnet/2002/10/07/webservices.html



What I don't get is how to setup the proxy class, and/or tcpTrace to actually view the requests/responses.



I tried by setting the destination to my remote URL (the one with the web service), port 80 and the local to 'localhost', port 8080.



I then tried to setup the proxy on 'localhost:8080'. Finally, I called my web service, replacing the remote IP with 'localhost:8080'. The proxy was on the web service proxy class.



So, question:



- what the heck does the WebProxy class do?

- what IP/host name would you set the proxy to to get the port listener to actually listen?

- how do I test if I have thing setup correctly, like with a web browser?



Any info would be really helpful. I'm starting to loose my mind...Crazy





GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search