Announcement Announcement Module
Collapse
No announcement yet.
Spring WS / JAXB / DataSet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring WS / JAXB / DataSet

    I am attempting to call a web service using the marshalSendAndReceive method. It looks as if the request is marshalling correctly using JAXB, the issue occurs when I am unmarshalling. I am not getting any exceptions thrown when unmarshelling, however my properties within my unmarshalled response object are empty.

    When I run a simple test using the sendSourceAndReceiveToResult method and pass it some static xml the response I am receiving is as follows.
    Code:
    <Subscriber_Get_DetailsByEmailResponse xmlns="http://mynamespace.com/">
    <Subscriber_Get_DetailsByEmailResult>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
    	<xs:element msdata:IsDataSet="true" msdata:UseCurrentLocale="true" name="NewDataSet">
    		<xs:complexType>
    			<xs:choice maxOccurs="unbounded" minOccurs="0">
    				<xs:element name="Table">
    					<xs:complexType>
    						<xs:sequence>
    							<xs:element minOccurs="0" name="City" type="xs:string"/>
    							...
    						</xs:sequence>
    					</xs:complexType>
    				</xs:element>
    			</xs:choice>
    		</xs:complexType>
    	</xs:element>
    </xs:schema>
    <diffgr:diffgram xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    	<NewDataSet xmlns="">
    		<Table diffgr:id="Table1" msdata:rowOrder="0">
    			<City>Chicago</City>
    			.....
    		</Table>
    	</NewDataSet>
    </diffgr:diffgram>
    </Subscriber_Get_DetailsByEmailResult>
    </Subscriber_Get_DetailsByEmailResponse>
    This is my first time working with any sort of web services so I am unsure if this is a typical response, however based on my experience working with DOM/SAX I find it odd that the schema and data our being returned, and not just the data. I have been told by the web service provider that the returned xml is a Microsoft Active Data object (DataSet).

    Now I will get to what I am actually trying to accomplish, and that is using Spring WS with JAXB. Below is what I have as far as Spring WS code and schema that is used by JAXB to generate my source files.


    XSD (note: I am using XJC to generate my .java files from this schema)
    Code:
    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    	targetNamespace=" http://mynamespace.com/" xmlns=" http://mynamespace.com/
    	elementFormDefault="qualified">
    	
    	
    	<xs:element name="Subscriber_Get_DetailsByEmail">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="AccountID" type="xs:string"/>
    				<xs:element name="DatabaseName" type="xs:string"/>
    				<xs:element name="Email" type="xs:string"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>
    	
    	
    	<xs:element name="Subscriber_Get_DetailsByEmailResponse">
    		<xs:complexType>
    			<xs:sequence>
    				<xs:element name="Subscriber_Get_DetailsByEmailResult" type="Subscriber_Get_DetailsByEmailResult"/>
    			</xs:sequence>
    		</xs:complexType>
    	</xs:element>	
    	
    
    	<xs:complexType name="Subscriber_Get_DetailsByEmailResult">
    		<xs:sequence>
    			<xs:element name="City" type="xs:string"/>
    			...
    		</xs:sequence>		
    	</xs:complexType>	
    	
    	
    </xs:schema>
    Spring WS code that invokes the service
    Code:
    ObjectFactory factory = new ObjectFactory();
    SubscriberGetDetailsByEmail subscriberGetDetailsByEmail = factory.createSubscriberGetDetailsByEmail(); 
    subscriberGetDetailsByEmail.setAccountID("12345");
    subscriberGetDetailsByEmail.setDatabaseName("main");
    subscriberGetDetailsByEmail.setEmail("[email protected]"); 
    
    SubscriberGetDetailsByEmailResponse response = (SubscriberGetDetailsByEmailResponse)getWebServiceTemplate().marshalSendAndReceive(subscriberGetDetailsByEmail);
    SubscriberGetDetailsByEmailResult emailResult = response.getSubscriberGetDetailsByEmailResult();
    It seems as if the request portion of the code is working correctly (i.e. I am receiving a response) however all the values in my emailResult are empty.

    Any thoughts on what is going wrong.

    Thanks,

    Keith

  • #2
    Any thoughts on this one?

    Thanks,

    Keith

    Comment


    • #3
      Well, it seems like there is no relation between your XSD, and the one returned from the web service (the one with the dataset in it). Looks like the web service is just sending you a .NET-specific object (the DataSet), and only a diff of that. Not very helpful for people not on .NET.

      So the way to go forward is to go to the .NET service URL (it probably ends with an .asmx suffix), get that WSDL, and use xjc on that. Hopefully, that will give you some objects which can be used instead.

      Comment


      • #4
        Any alternatives?

        I've run into the same issue with .Net based WS
        I was trying to use JAXB2 to do the unmarshalling but I think I can forget that.
        I looks like I have two choices:
        1) try to parse the response and pick out the bits I'm interested in
        2) try to transform the response into something JAXB will understand

        Has anyone come across a clean solution to this - so much for WS interoperability when MS is involved

        P.S.
        I implemented a simple test unmarshaller and I see the Source being handed in is a javax.xml.transform.dom.DOMSource so I can probably try some xpath to get at the bits I need
        Last edited by nedge; Sep 7th, 2009, 11:46 AM.

        Comment

        Working...
        X