4

I have a WCF Service; this service has an operation that receives an argument of type Request. This is only the base type, and when calling the operation we actually send a value of type Request_V1 (which inherts from Request), that has the complete implementation of the request I want to send.

When trying to test the service using soapUI, I'm able to create the complex type of type Request_V1 (adding the proper namespace) but for some reason, the service is receiving the value as if it were of Request type.

Reading about ServiceKnowType, I found out here that I need to specify somehow explicitly in the client this inheritance relationship, but I haven't found any info regarding how to do it on soapUI

Has anybody experienced and solved the same issue?

Thanks

Community
  • 1
  • 1
pollirrata
  • 5,188
  • 2
  • 32
  • 50

3 Answers3

2

You also have to specify the type in the SOAP message. For example

<Request i:type="d:RequestV1">

...

where i is defined as XML-Instance namespace

josagyemang
  • 503
  • 5
  • 9
1

On service side, you need to typecast to specific derived type.

operation (Request request){
    if(!(request is Request_V1)){
        throw Excetion("Unknown type!");
    }

    var request_v1 = Request as Request_V1;

    // use request_v1
}

On SOAP UI side, specify type as below:

<soapenv:Body xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
  <ns1:OperationName>
     <ns1:request i:type="ns2:Request_V1">

Make sure you have defined ns1 and ns2 before referring to them.

zendu
  • 1,108
  • 1
  • 14
  • 36
0

You don't specify the inheritance in the client, rather in the service. SOAPUI shouldn't have a problem with that. Check you have the correct declarations on your data contracts. This might help - Deserialize Abstract Class.

Community
  • 1
  • 1
stephenl
  • 3,119
  • 4
  • 22
  • 22
  • All the needed `KnownType` attributes have been already added to the DataContract, but for some reason is not working :( – pollirrata Mar 26 '13 at 23:03