Returning class object in web service geting changed its namespace
I have a web method, which has a user defined class as its return type. This class in present in another namespace. Now in my web service consumer class when I am trying the fetch the user defined class by using the web method, the namespace of the 开发者_JAVA技巧user defined class is getting changed. And its not able to cast to its original namespace. So where I am wrong? And how to solve it?
Update:
In Client Side I have Written,
GlobalSetting.ParentJob obj = (WS_SupportOutput.WS_Output()).GetJob(Jobnumber);
Where GetJob() in the function in my web service whose Return Type is GlobalSetting.ParentJob
. But now the return type is showing as WS_SupportOutput.ParentJob
not GlobalSetting.ParentJob
.
You are consuming a SOAP webservice that could be written in any language, and as a result doesn't have any concept or knowledge of the namespace or class the data came from.
The webservice WSDL describes the result to be a complex value, and so the consumer, .Net, builds a class to drop the values into. This looks identical value wise, but you will note that all methods are missing, as are all private values.
In short, this is normal behaviour, and if you really need the values to end back up in the same class, you will need to write code to translate the webservice result as needed on the caller.
The class will then need to be shared by both projects, so therefore in a common library.
Sadly, .Net doesn't offer support to do this for us when using SOAP webservices.
you can re-serialize the object and change the namespaces, has many examples on the web to find it if I give you the one I use.
精彩评论