views:

911

answers:

4

Never seen this one 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's returning an ImplementationResponse, as expected. But all of the fields in that object are null. Which is not expected. The WebService, currently, just returns some constant dummy data. We've tested this on another developer's machine, works just fine.

I suppose I should also note that the WebService should throw an exception if I pass null into the GetValue method. It doesn't. Not for me.

Any idea what could be wrong with my environment that could make a WebService return an object, but make every value in that object null? And somehow 'magically' return this mystery object when it should be throwing an exception?

+2  A: 

Are the fields marked with < DataMember()> attributes as they won't serialize 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 trace viewer to analyse the messages sent between the client and server. For info see:

http://stackoverflow.com/questions/560370/handling-wcf-proxy-null-return-issue

Tanner
Good thing to mention, used the WCF Log Viewer to look at the trace, and here's the bizzare thing, it's not showing up in the logs. Not even an error, like it didn't even try to make the request.
Xaiter
Oh, yeah, also made sure that stuff was tagged with DataMember. It is.
Xaiter
A: 

I suppose I should also note that the WebService should throw an exception if I pass null into the GetValue method

You didn't pass null here,you passed in a request object.

Also, you need be able to debug into the web service to see what's going on there. I assume you are implementing this internally, since you can set it to constant dummy value.

J.W.
I know I passed a value in the example code. I'm saying IF I pass null into the method.
Xaiter
+4  A: 

That usually happens when there's a discrepancy between the generated code and the xml being returned by the web service so it cannot be deserialized.

Grab the wsdl again, regenerate all the proxy classes and try again. Make sure you are sending the correct dummy data.

Update:

This used to happen to me a lot because the web services weren't managed by my team and we wouldn't get any notice of changes made to the service. We ended up intercepting the soap messages in the web service pipeline for debugging. Here's a great resource to get you on your way.

You don't need to change anything in the pipeline, just grab the soap messages and save them so you have debug later. Most of the times it turned out to be just that, a change in the contract. Other times we wouldn't have a contract so there was no way of knowing of changes without catching the envelopes.

Anyway, even if it's not your problem I think it's a good thing to have.

Rezlaj
I thought this might be it, I gave your suggestion a shot. No dice.
Xaiter
A: 

Here is a nice post about this issue. http://sivakrishnakuchi.blogspot.com/2010/05/how-to-create-wcf-service-application.html

Siva