Announcement Announcement Module
Collapse
No announcement yet.
JAXB unmarshalling exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JAXB unmarshalling exception

    Hello all

    I'm using SpringWS 1.5.7
    Server Information:
    Tomcat Version: Apache Tomcat/6.0.20
    JVM Version: 1.6.0_14-b08
    JVM Vendor: Sun Microsystems Inc.
    OS Name, OS Version: Windows XP 5.1
    OS Architecture : x86

    I have a small problem with the JAXB2 (un)marshalling implementing in my project.

    I have made test with JDom and @Endpoint with @XpathParam(), and as long as I not have a own implemented Object all is working fine.

    But as soon as I try to marshal or unmarshal a Business-Object that I implemented myself its no more working, I get the following error message

    Code:
             <faultcode>SOAP-ENV:Server</faultcode>
             <faultstring xml:lang="en">JAXB unmarshalling exception: unexpected element (uri:"http://ws.grpart.generali.ch", local:"getSettings"). Expected elements are (none); nested exception is javax.xml.bind.UnmarshalException: unexpected element (uri:"http://ws.grpart.generali.ch", local:"getSettings"). Expected elements are (none)</faultstring>
    I serached on the internet, but could not really find any help
    I tray all possible options but even a very small example like this:

    package ch.generali.grpart.ws;


    Code:
    import ch.generali.grpart.Settings;
    import org.springframework.oxm.Marshaller;
    //import org.springframework.oxm.Unmarshaller;
    import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;
    
    public class MarshallingOrderEndpoint extends AbstractMarshallingPayloadEndpoint {
    
    .....
        protected Object invokeInternal(Object request) throws Exception {
            System.out.println("in invokeInternal request val: " + request);
            String paraString = (String) request;
            Settings languageRequest = new Settings();
            languageRequest.setFooBar("Heureka");
            return languageRequest;
        }
    }
    And the follwowing wsdl file: order.wsdl

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
        xmlns:sch="http://grpart.generali.ch"
        xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:tns="http://ws.grpart.generali.ch"
        targetNamespace="http://ws.grpart.generali.ch"
        >
        <wsdl:types>
            <schema targetNamespace="http://ws.grpart.generali.ch"
                xmlns="http://www.w3.org/2001/XMLSchema"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:impl="http://ws.grpart.generali.ch"
                xmlns:s="http://grpart.generali.ch">
            <import namespace="http://grpart.generali.ch"/>
    
                <element name="getSettingsRequest" type="xsd:string" />
    
                <element name="getSettingsResponse" type="s:Settings" />
            </schema>
            <schema targetNamespace="http://grpart.generali.ch"
                xmlns="http://www.w3.org/2001/XMLSchema"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:s="http://grpart.generali.ch"
             >
                <complexType name="Settings">
                    <sequence>
                        <element name="fooBar" type="xsd:string"/>
                    </sequence>
                </complexType>
            </schema>
        </wsdl:types>
        <wsdl:message name="getSettingsResponse">
            <wsdl:part element="tns:getSettingsResponse" name="parameters">
            </wsdl:part>
        </wsdl:message>
        <wsdl:message name="getSettingsRequest">
            <wsdl:part element="tns:getSettingsRequest" name="parameters">
            </wsdl:part>
        </wsdl:message>
        <wsdl:portType name="OrderSystem">
            <wsdl:operation name="getSettings">
                <wsdl:input message="tns:getSettingsRequest" name="getSettingsRequest">
                </wsdl:input>
                <wsdl:output message="tns:getSettingsResponse" name="getSettingsResponse">
                </wsdl:output>
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="OrderSystemSoap11" type="tns:OrderSystem">
            <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
            <wsdl:operation name="getSettings">
                <soap:operation soapAction=""/>
                <wsdl:input name="getSettingsRequest">
                    <soap:body use="literal"/>
                </wsdl:input>
                <wsdl:output name="getSettingsResponse">
                    <soap:body use="literal"/>
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="OrderSystemService">
            <wsdl:port binding="tns:OrderSystemSoap11" name="OrderSystemSoap11">
                <soap:address location="/"/>
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    is not working

    Spring config

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:oxm="http://www.springframework.org/schema/oxm"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-2.5.xsd
           http://www.springframework.org/schema/oxm http://www.springframework.org/schem...ng-oxm-1.5.xsd
           ">
    
    
        <bean id="orderEndpoint" class="ch.generali.grpart.ws.MarshallingOrderEndpoint">
            <constructor-arg ref="marshaller"/>
        </bean>
        <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="classesToBeBound">
                <list>
                    <value>java.lang.String</value>
                    <value>ch.generali.grpart.Settings</value>
                </list>
            </property>
        </bean>
    
        <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
            <property name="mappings">
                <props>
                    <prop key="{http://ws.grpart.generali.ch}getSettings">orderEndpoint</prop>
                </props>
            </property>
        </bean>
    
        <bean id="order" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
            <constructor-arg value="/WEB-INF/order.wsdl"/>
        </bean>
    </beans>
    and the web.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
             version="2.4">
    
        <display-name>Archetype Created Web Application</display-name>
    
        <servlet>
            <servlet-name>spring-ws</servlet-name>
            <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>spring-ws</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    
    </web-app>
    isn't working.

    I rayed now for many days to find a solution for the problem, but somehow I can not really find a one.

    Is there anybody how could give me a hint where I am misunderstanding the concept.

    Thanks for you help

    Greeting Chris
Working...
X