Handle JAXB @XMLIDRef in .NET

2019-03-22 12:17发布

问题:

I'm writing a web service using jax-ws. One of web service's methods returns bean, which contains reference to its parent. To prevent cyclic references I'm using JAXB @XMLID and @XMLIDRef annotations in my bean.

Then i'm generating proxy class for java client everything works OK and id resolves to Object properties. But then I'm generating web-service client proxy in Visual Studio for .NET, it interprets idrefs as string properties, not an Object.

Is it possible to generate proxy classes from wsdl for .NET with resolving of idrefs?

回答1:

Out of the box Microsoft's tools won't do the job for you. You'll have to ask Microsoft to change the

wsdl generation tools. E.g.:

  • wsdl.exe: http://msdn.microsoft.com/library/7h3ystb6(VS.80).aspx
  • svcutil.exe: http://msdn.microsoft.com/en-us/library/aa347733.aspx

In a recent project I had to work around the short comings of these tools and modified the generated code using a Basic Script fixing what was not generated the way needed (in our case incompatibilities with the Java side wsdl generation)