all groups > dotnet web services > june 2007 >
You're in the

dotnet web services

group:

Debug webservice


Debug webservice Peter K
6/27/2007 6:03:34 AM
dotnet web services:
Hi

I have a VS2005 c# solution which includes a webservice and a windows
application which uses the webservice.

How do I "debug" into the webservice from the application?

I can for example debug/attach to aspnet_wp.exe and access the webservice
from a browser - and there I can hit breakpoints in the webservice (but
unfortunately not access the more complex methods in my webservice).

But I can't work out how to achieve the same from my windows application.


Thanks,
RE: Debug webservice Mark
6/27/2007 6:16:01 AM

[quoted text, click to view]

On a related note, how would one get a look at the soap packets (request and
response) when using the wrapper classes generated from a wsdl? The wrapper
classes try to hide the conversation and it would be nice to see the
specifics of the question.

And in my case, I'm talking to a web service written in php that doesn't
seem to give proper soap error responses, so I really need to see what's
getting sent back.

Thanks
Mark
RE: Debug webservice oldVB3r
6/27/2007 7:34:00 AM
One options for getting at the Soap message content is to use a "universal"
client such as the System.Net.HttpWebRequest object to send and recieve raw
Soap (see the second post to WebClient generates exception: header must be
modified using ... 6/22/07). If you have a WCF client to your web service,
you can add the following local to the class containing the client object
creation and web service call:

Public Shared results As String

Private Class MyBehavior
Implements ServiceModel.Description.IEndpointBehavior

Public Sub AddBindingParameters(ByVal endpoint As
System.ServiceModel.Description.ServiceEndpoint, ByVal bindingParameters As
System.ServiceModel.Channels.BindingParameterCollection) Implements
System.ServiceModel.Description.IEndpointBehavior.AddBindingParameters

End Sub

Public Sub ApplyClientBehavior(ByVal endpoint As
System.ServiceModel.Description.ServiceEndpoint, ByVal clientRuntime As
System.ServiceModel.Dispatcher.ClientRuntime) Implements
System.ServiceModel.Description.IEndpointBehavior.ApplyClientBehavior
clientRuntime.MessageInspectors.Add(New MyInspector)
End Sub

Public Sub ApplyDispatchBehavior(ByVal endpoint As
System.ServiceModel.Description.ServiceEndpoint, ByVal endpointDispatcher As
System.ServiceModel.Dispatcher.EndpointDispatcher) Implements
System.ServiceModel.Description.IEndpointBehavior.ApplyDispatchBehavior

End Sub

Public Sub Validate(ByVal endpoint As
System.ServiceModel.Description.ServiceEndpoint) Implements
System.ServiceModel.Description.IEndpointBehavior.Validate

End Sub
End Class

Private Class MyInspector
Implements ServiceModel.Dispatcher.IClientMessageInspector

Public Sub AfterReceiveReply(ByRef reply As
System.ServiceModel.Channels.Message, ByVal correlationState As Object)
Implements
System.ServiceModel.Dispatcher.IClientMessageInspector.AfterReceiveReply
results = vbCrLf
results &= "=====AfterReceiveReply================"
results &= vbCrLf
results &= reply.ToString
results &= vbCrLf
results &= "======================================"
results &= vbCrLf

End Sub

Public Function BeforeSendRequest(ByRef request As
System.ServiceModel.Channels.Message, ByVal channel As
System.ServiceModel.IClientChannel) As Object Implements
System.ServiceModel.Dispatcher.IClientMessageInspector.BeforeSendRequest
Return Nothing
End Function
End Class

The calling code would do the following to invoke this behavior assuming the
service object is name WsClient and you have a Textbox control named
txtResults:

WsClient.Endpoint.Behaviors.Add(New MyBehavior)

''' code to invoke your service goes here

'Display the response from the web servive:

txtResults.Text &= results

''' rest of your code...

AddThis Social Bookmark Button