I am using the XFire plugin wizard for Eclipse to create the proxy classes from 
a .NET Web Service and am using JAXB. 
 
  AnnotationServiceFactory asf = new AnnotationServiceFactory(      new 
Jsr181WebAnnotations(),       tm,       new AegisBindingProvider(new 
JaxbTypeRegistry()));
The proxy classes are generated fine.  The problem I am having is that when the 
XML 
  <soap:Body>    <GetPersonResponse xmlns="urn:emp:service">      
<GetPersonResult>        <Name>Bob the Builder</Name>        <Address 
xsi:type="HomeAddress">          <HouseNumber>987654 ELM STREET</HouseNumber>   
     </Address>      </GetPersonResult>    </GetPersonResponse>  </soap:Body>
 
is parse, the Address field should be instantiating a HomeAddress type which is 
aderived type of Address.
 
I have tracked the problem to 
com.sun.xml.bind.v2.runtime.unmarshaller.StAXStreamConnector 
where there is a method private void handleStartElement() in which ncCount is 
being set to 
0 (zero) 
 
        // start namespace bindings        int nsCount = 
staxStreamReader.getNamespaceCount();
 
which causes the next block of code to not run
 
        for (int i = 0; i < nsCount; i++) {            
visitor.startPrefixMapping(                
fixNull(staxStreamReader.getNamespacePrefix(i)),                
fixNull(staxStreamReader.getNamespaceURI(i)));        }
 
Because this is not being done, I get an exception "Could not unmarshall type."
As a total hack, I add visitor.startPrefixMapping("", "urn:emp:service") to the 
watch list, everything goes through just fine.  I can start debugging over and 
over all day long and this will continue to work.  As soon as I remove this 
from the watch list, I get the original exception again.
If I change the .NET Service to have the Service in one namespace and the data 
in anothernamespace, the following XML is generated
  <soap:Body>    <GetPersonResponse xmlns="urn:emp:service">      
<GetPersonResult xmlns="urn:emp:data">        <Name>Bob the Builder</Name>      
  <Address xsi:type="HomeAddress">          <HouseNumber>987654 ELM 
STREET</HouseNumber>        </Address>      </GetPersonResult>    
</GetPersonResponse>  </soap:Body>
 
the only difference between this and the XML above is the addition of 
xmlns="urn:emp:data" on <GetPersonResult>.
when I get to handleStartElement() again nsCount is 1 and the code goes through 
without incident.  
 
I am publishing this information in an effort to solicit help in finding the 
solutionas I am a .NET developer and not a Java developer.  Getting to this 
point has consumeda lot of time and any help in resolving this would greatly be 
appreciated.
 
If you are interested, I can send the source code directly or you can get it 
off of myblog: http://webbertsolutions.spaces.live.com/
 
Thanks,Dave
_________________________________________________________________
Your friends are close to you. Keep them that way.
http://spaces.live.com/signup.aspx

Reply via email to