Web service returns an object with zero fields

I've never seen this before.

WebService.Implementation imp = new WebService.Implementation(); WebService.ImplementationRequest req = new WebService.ImplementationRequest(); return imp.GetValue(req); 

The object that imp returns is not null. It returns a request for execution, as expected. But all fields in this object are equal to zero. Which is not expected. WebService, currently, just returns some persistent dummy data. We tested it on another developer's machine, everything is fine.

I should also note that the WebService should throw an exception if I pass null to the GetValue method. This is not true. Not for me.

Any idea what might be wrong in my environment that might cause the WebService to return an object, but make every value in that object null? And somehow, “magically” return this object of mystery when it should throw an exception?

+4
source share
3 answers

This usually happens when there is a mismatch between the generated code and the xml returned by the web service, so it cannot be deserialized.

Run wsdl again, restore all proxy classes, and try again. Make sure you send the correct dummy data.

Update:

This often happened to me because my services were not controlled by web services, and we did not receive notifications about changes made to this service. We have completed the capture of soap messages in the web services pipeline for debugging. Here is a great resource to help you along the way.

You do not need to change anything in the pipeline, just take soap messages and save them so that you can debug later. In most cases, this was exactly the case, a change in contract. In other cases, we would not have a contract, so there would be no way to find out about the changes without catching up with the envelopes.

In any case, even if it’s not your problem, I think it’s good.

+9
source

Fields marked with the <DataMember ()> symbol since they will not be serialized otherwise?

 <DataMember()> _ Public Property SomeField() As String Get Return m_strSomeField End Get Private Set(ByVal value As String) m_strSomeField= value End Set End Property 

Also, consider using a trace viewer to analyze messages sent between the client and server. For information see:

fooobar.com/questions/866818 / ...

+3
source

I suppose I should also note that the WebService should throw an exception if I pass null to GetValue Method

You did not pass null here, you passed the request object.

In addition, you need to be able to debug the web service to find out what is going on there. I assume that you implement this internally, since you can set it to a constant dummy value.

0
source

All Articles