views:

76

answers:

1

I am testing a web-service that gets an object as a parameter. To create this object I go through an online store that we are maintaining and the end result is a rather big object, we can call it BO, sent to a web-service.

Now we seem to have a bug that comes up when BO is in a specific state. I tediously go through the online store to create the state of BO I am examining and then watch in debug how the web-service handles it.

This can happen several times and each time takes up time and mental energy. Still I can watch the right state of BO in my debug mode. I can serialize it to XML which is convenient. I dream of being able to serialize it to c# code. I haven't found it on the web. I have found serialize to XML, and serialize to JSON.

My questions are: Do you know how I can serialize it to c# code, so I can easily make a test case for this specific business case?

Do you have other suggestions about how to solve these kinds of problems?

Helpful answer from Sixto Saez

The simplest way to save the state of a service call request is to intercept and store the soap message sent to the service since it stores the complete object state. You could use a tool like Fiddler to access the soap message and save it to a file. Next you'd write a simple app that would use the .NET HttpWebRequest object to submit the stored soap to the service.

A: 

The problem you are trying to solve is to retrieve the stored state of an object so you can call a service repeatedly with that state for debugging. Sounds like you also want to change the state prior to making the service call.

One option for this scenario is to use the Visual Studio tool named WcfTestClient. This link documents how to use the client. Once you run it and populate the "BO" state, you can repeatedly edit and resubmit the updated parameter to the service method. Unfortunately, you'll have to manually populate the parameter each time the WcfTestClient app is run since there is no way to save the parameter values. Hope this helps!

Sixto Saez
I don't have to change the "BO". Im just talking about repeatedly testing/debugging the same state.
Skúli
I really would like to automate the population of the state
Skúli
The simplest way to save the state of a service call request is to intercept and store the soap message sent to the service since it stores the complete object state. You could use a tool like Fiddler to access the soap message and save it to a file. Next you'd write a simple app that would use the .NET HttpWebRequest object to submit the stored soap to the service.
Sixto Saez
True. Would work.
Skúli