Tuesday, June 08, 2004

Java client for an ASP.NET web service, part 2

I got it to work, with modification. Here’s a snippet of what the client was trying:
<StartEvaluation xmlns="http://ottawa.byu.edu/Emar">
	<parameters href="#id0" xmlns=""/>
</StartEvaluation>
<multiRef id="id0" ...>
	<PIN xsi:type="xsd:string">TESTPIN</PIN>
	<QuestionnaireName xsi:type="xsd:string">READY</QuestionnaireName>
</multiRef>
I have never seen the href->id link notation before, but I researched it, and I believe that, if .NET were interpreting it correctly, that this is how it would be re-assembled:
<StartEvaluation xmlns="http://ottawa.byu.edu/Emar">
	<parameters>
		<PIN xsi:type="xsd:string">TESTPIN</PIN>
		<QuestionnaireName xsi:type="xsd:string">READY</QuestionnaireName>
	</parameters>
</StartEvaluation>
This is not according to the spec in the WSDL. Sending this literal text also generated the bug. The PIN and QuestionnaireName tags must be immediately descendants of the StartEvaluation tag, like this:
<StartEvaluation xmlns="http://ottawa.byu.edu/Emar">
	<PIN xsi:type="xsd:string">TESTPIN</PIN>
	<QuestionnaireName xsi:type="xsd:string">READY</QuestionnaireName>
</StartEvaluation>
This does actually achieve the desired result. I am not sure if I am interpreting the HREF-ID linking correctly. Please tell me whether I am correct or not on how the XML should be interpreted. If I am, then that seems to explain why the error is happening. I believe there are two solutions:
  1. You modify your client code so that it emits the XML compliant with this service.
  2. I write a SOAP filter that intercepts requests like the ones you are sending and refactors them so that the web service can understand it.
Option two may be longer than option 1 to implement, since I have my hands pretty full. I do know that ColdFusion and my WSDL2Java utility do just fine with the web service as is, so I would hope that there is just an attribute somewhere in your object that you can set to turn off the multiref thing.

No comments:

Post a Comment