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

  • Axis2 to Spring-WS

    Hello Spring Community:

    I am trying to convert an Axis2 Web Service to a Spring-WS, and, if that's possible, then add Spring Framework 3.0 management to this new Spring-WS and a separate Java service. I already have a WSDL defined and auto-generated Axis2 classes that I would like to reuse, if possible, I realize they will need to be edited of course. The Axis2 Web Service's client is Flex3 and I would like to minimize any changes it may need. The Axis2 Web Service is SOAP based so, if possible, I'd like to make the Spring-WS also SOAP based. I am having a bit of difficulty following the tutorials mainly because they seem to jump around a lot stating divergent viewpoints. Does anyone have a step-by-step example of performing this conversion that sticks with one development pattern without introducing other trains-of-thought? It seems like this should be fairly straight-forward but apparently I am missing something because when I don't get a spring error about a malformed bean, I get a blank 404 HTTP error page on Tomcat.

    FYI-Another idea floating around is changing the Web Service to CXF and then adding Spring Framework 3.0 management to that. Does anyone have any ideas about that?

    Here's a snippet from my existing WSDL that I would really like to reuse. Note: the xxx's are simply for obscuring company and product names.
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions targetNamespace="http://xxx.xxx.com" xmlns:impl="http://xxx.xxx.com" xmlns:intf="http://xxx.xxx.com" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
      <wsdl:types>
        <xsd:schema elementFormDefault="qualified" targetNamespace="http://xxx.xxx.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    			<xsd:element name="AuthenticateUser">
    				<xsd:complexType>
    					<xsd:sequence>
    						<xsd:element name="userName" type="xsd:string"/>
    						<xsd:element name="password" type="xsd:string"/>
    					</xsd:sequence>
    				</xsd:complexType>
    			</xsd:element>
    			<xsd:element name="AuthenticateUserResponse">
    				<xsd:complexType>
    					<xsd:sequence>
    						<xsd:element name="osName" type="xsd:string">
    						</xsd:element>
    					</xsd:sequence>
    				</xsd:complexType>
    			</xsd:element>
      <wsdl:message name="AuthenticateUserRequest">
        <wsdl:part name="parameters" element="impl:AuthenticateUser">
        </wsdl:part>
      </wsdl:message>
      <wsdl:message name="AuthenticateUserResponse">
        <wsdl:part name="parameters" element="impl:AuthenticateUserResponse">
        </wsdl:part>
      </wsdl:message>
      <wsdl:portType name="xxxSOAP">
        <wsdl:operation name="AuthenticateUser">
          <wsdl:input message="impl:AuthenticateUserRequest">
        </wsdl:input>
      </wsdl:portType>
      <wsdl:binding name="xxxSOAPSoapBinding" type="impl:xxxSOAP">
        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
        <wsdl:operation name="AuthenticateUser">
          <wsdlsoap:operation soapAction="http://xxx.xxx.com/AuthenticateUser"/>
          <wsdl:input>
            <wsdlsoap:body use="literal"/>
          </wsdl:input>
          <wsdl:output>
            <wsdlsoap:body use="literal"/>
          </wsdl:output>
        </wsdl:operation>
      </wsdl:binding>
      <wsdl:service name="xxx">
        <wsdl:port name="xxxSOAP" binding="impl:xxxSOAPSoapBinding">
          <wsdlsoap:address location="http://localhost:8080/xxxSOAP/services/xxxSOAP"/>
        </wsdl:port>
      </wsdl:service>
    </wsdl:definitions>
    Other software versions being used: Spring-WS 1.5.9, Spring Framework 3.0, Java 6, Tomcat 6.

    Thank you all, in advance, for any assistance you can provide. Any information would be of great use.

    Sincerely,
    Mike Sucena
    Software Engineer

  • #2
    Current Spring-WS implementation

    In an effort to spur some thought about my topic here I am prepared to provide additional information relating to some work I have already done for this problem. Please let me know if I am on the right track.

    Here is my 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>xxx Web Service</display-name>
    
        <servlet>
            <servlet-name>spring-ws</servlet-name>
            <servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
            <init-param>
                <param-name>transformWsdlLocations</param-name>
                <param-value>true</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>spring-ws</servlet-name>
            <url-pattern>/*</url-pattern>
        </servlet-mapping>
    
        <servlet-mapping>
            <servlet-name>spring-ws</servlet-name>
            <url-pattern>/axis2/services/*</url-pattern>
        </servlet-mapping>
    
    </web-app>
    Here is my spring-ws-servlet.xml:
    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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                               http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd"
           xmlns:util="http://www.springframework.org/schema/util">
    
        <!--
        <bean id="payloadMapping" class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
            <property name="defaultEndpoint" ref="xxxSpringWSEndpoint"/>
            <property name="interceptors">
                <list>
                    <ref local="validatingInterceptor"/>
                    <ref local="loggingInterceptor"/>
                </list>
            </property>
        </bean>
        -->
    
        <bean id="payloadMapping" class="org.springframework.ws.soap.server.endpoint.mapping.SoapActionEndpointMapping">
            <property name="mappings">
                <props>
    		<prop key="http://xxx.xxx.com/AuthenticateUser">xxxSpringWSEndpoint</prop>
    		<prop key="http://xxx.xxx.com/GetVersions">xxxSpringWSEndpoint</prop>
                </props>
    	</property>
            <property name="interceptors">
                <list>
                    <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor" />
                    <bean class="org.springframework.ws.soap.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor" />
                </list>
            </property>
        </bean>
    
        <!-- -->
        <bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
            <!--
            <property name="soapVersion">
                <util:constant static-field="org.springframework.ws.soap.SoapVersion.SOAP_12"/>
            </property>
            -->
        </bean>
        <!-- -->
    
        <!--
        <bean id="validatingInterceptor"
              class="org.springframework.ws.soap.server.endpoint.interceptor.PayloadValidatingInterceptor">
            <property name="xsdSchema" ref="schema"/>
            <property name="validateRequest" value="true"/>
            <property name="validateResponse" value="true"/>
        </bean>
    
        <bean id="loggingInterceptor" class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor">
            <description>
                This interceptor logs the message payload.
            </description>
        </bean>
        -->
    
        <bean id="xxxSpringWSEndpoint" class="com.xxx.xxx.ws.xxxSpringWSEndPoint">
            <constructor-arg ref="xxxService"/>
            <constructor-arg ref="marshaller"/>
        </bean>
    
        <bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
            <property name="classesToBeBound">
                <list>
                    <value>com.xxx.xxx.AuthenticateUser</value>
                    <value>com.xxx.xxx.AuthenticateUserResponse</value>
                    <value>com.xxx.xxx.GetVersions</value>
                    <value>com.xxx.xxx.GetVersionsResponse</value>
                </list>
            </property>
            <!--<property name="schema" ref="schema"/>-->
        </bean>
    
        <bean id="xxxWS" class="org.springframework.ws.wsdl.wsdl11.SimpleWsdl11Definition">
            <constructor-arg value="/WEB-INF/wsdl/xxxWS.wsdl"/>
        </bean>
    
        <!--
        <bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">
            <description>
                This bean definition contains the XSD schema.
            </description>
            <property name="xsd" value="/WEB-INF/xxxWS.xsd"/>
        </bean>
        -->
        
        <bean id="xxxService" class="com.xxx.xxx.ws.service.impl.xxxServiceImpl">
            <description>
                This bean is our "business" service.
            </description>
        </bean>
    
    </beans>
    Here's my xxxSpringWSEndpoint java file:
    Code:
    package com.xxx.xxx.ws;
    
    import com.xxx.xxx.ws.service.xxxService;
    import com.xxx.xxx.AuthenticateUser;
    import com.xxx.xxx.AuthenticateUserResponse;
    import com.xxx.xxx.GetVersions;
    import com.xxx.xxx.GetVersionsResponse;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.oxm.Marshaller;
    import org.springframework.ws.context.MessageContext;
    import org.springframework.ws.server.endpoint.AbstractMarshallingPayloadEndpoint;
    
    /**
     *
     * @author msucena
     */
    public class xxxSpringWSEndPoint extends AbstractMarshallingPayloadEndpoint
    {
        /** Logging */
        private static final Log log = LogFactory.getLog(xxxSpringWSEndPoint.class);
    
        private xxxService xxxService;
    
        public xxxSpringWSEndPoint(xxxService svc, Marshaller marsh)
        {
            super(marsh);
            xxxService = svc;
        }
    
        @Override
        protected boolean onUnmarshalRequest(MessageContext messageContext,
    			Object requestObject) throws Exception
        {
            log.debug("onUnmarshalRequest");
    	return super.onUnmarshalRequest(messageContext, requestObject);
        }
    
        @Override
        protected void onMarshalResponse(MessageContext messageContext,
                        Object requestObject, Object responseObject)
        {
            log.debug("onMarshalResponse");
            super.onMarshalResponse(messageContext, requestObject, responseObject);
        }
    
    
        @Override
        protected Object invokeInternal(Object requestObj)
                throws Exception
        {
            log.debug("invokeInternal");
            if (requestObj instanceof AuthenticateUser)  //TODO, need to parse requestElement for proper condition
            {
                AuthenticateUser auReqObj = (AuthenticateUser)requestObj;
                AuthenticateUserResponse aurRespObj = new AuthenticateUserResponse();
    
                aurRespObj = xxxService.AuthenticateUser(auReqObj);
    
                return aurRespObj;
            }
            else if (requestObj instanceof GetVersions)
            {
                GetVersions gvReqObj = (GetVersions)requestObj;
                GetVersionsResponse gvrRespObj = new GetVersionsResponse();
    
                gvrRespObj = xxxService.GetVersions(gvReqObj);
    
                return gvrRespObj;
            }
            else  //unknown request type
            {
                return null;
            }
    
        }
    
    }
    The problem I am having right now is that my Flex client is not reaching the new Web Service. When I start the Web Service it compiles and builds but then I get a 405 error page in Tomcat with this error: The specified HTTP method is not allowed for the requested resource (). I can view my WSDL if I go to http://localhost:8060/xxxWS/xxxWS.wsdl or http://localhost:8060/xxxSpringWS/xxxWS.wsdl. Because of this I am not sure if my current problem is in the Web Service or the Flex client.

    Can anyone provide any additional information? Also, please let me know if providing any additional code would be of assistance.

    Sincerely,
    Mike Sucena
    Software Engineer
    Last edited by msucena; Mar 26th, 2010, 03:49 PM.

    Comment


    • #3
      Any inputs on this?

      Anyone have any input about this? When I create a new Spring-WS project what should I be setting its Context Path to, if anything? Do I need to define an XSD even if I already have a defined WSDL? Anyone know why the Airline sample doesn't include all files, namely files like:

      Code:
      import org.springframework.ws.samples.airline.schema.BookFlightRequest;
      import org.springframework.ws.samples.airline.schema.Flight;
      import org.springframework.ws.samples.airline.schema.GetFlightsRequest;
      import org.springframework.ws.samples.airline.schema.GetFlightsResponse;
      import org.springframework.ws.samples.airline.schema.Name;
      import org.springframework.ws.samples.airline.schema.ObjectFactory;
      import org.springframework.ws.samples.airline.schema.ServiceClass;
      import org.springframework.ws.samples.airline.schema.Ticket;
      
      -- this is the only file I have in the schema package
      import org.springframework.ws.samples.airline.schema.support.SchemaConversionUtils;
      FYI-If I cannot make any more progress on this I am going to start investigating using CXF instead of Spring Web Services.

      -Mike
      Last edited by msucena; Mar 29th, 2010, 12:20 PM.

      Comment


      • #4
        HTTP 405 Tomcat error when references server WSDL

        I have changed my Spring-WS example to generate a Dynamic WSDL. Why is it that if I go to http://<host>:<port>/<servlet_context>/name.wsdl I see the WSDL, but if I go to http://<host>:<port>/<servlet_context>/name?wsdl, which is how my Flex 3 client is locating the web service, I get a HTTP 405 error in Tomcat and my client cannot see my Spring-WS?

        -Mike

        Comment


        • #5
          The link below discusses why the ?wsdl traditionally used in Axis and other implementations is not used in Spring WS. Hope that helps.


          http://forum.springsource.org/showth...hlight=%3Fwsdl

          Comment

          Working...
          X