Results 1 to 2 of 2

Thread: help - problem with "Holiday" tutorial

Threaded View

  1. #1
    Join Date
    Mar 2006
    Posts
    12

    Default help - problem with "Holiday" tutorial

    Hi

    I am new to Spring WS and am having trouble with the "Holiday" tutorial.


    PROBLEM:
    When I run "mvn clean dependency:copy-dependencies package", it shows the example fails to compile!...

    Is anyone familiar with the Spring WS "Holiday" example??
    (e.g., "http://static.springframework.org/spring-ws/site/reference/html/tutorial.html#tutorial-creating-project")
    -- Is the "HumanResourceService" class cited in the compile error message (below) a generated class?... Or, is it to be found elsewhere?... Or, am I supposed to created it (If so, I don't know what its supposed to contain)


    The following exception stack is generated (this is a portion)
    Code:
    [INFO] ------------------------------------------------------------------------
    [ERROR] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Compilation failure
    
    C:\springwsmaven\holidayService\src\main\java\com\mycompany\hr\ws\HolidayEndpoint.java:[6,32] package com.mycompany.hr.service does not exist
    C:\springwsmaven\holidayService\src\main\java\com\mycompany\hr\ws\HolidayEndpoint.java:[21,18] cannot find symbol
    symbol  : class HumanResourceService
    location: class com.mycompany.hr.ws.HolidayEndpoint
    C:\springwsmaven\holidayService\src\main\java\com\mycompany\hr\ws\HolidayEndpoint.java:[23,27] cannot find symbol
    symbol  : class HumanResourceService
    location: class com.mycompany.hr.ws.HolidayEndpoint
    
    [INFO] ------------------------------------------------------------------------
    [INFO] For more information, run Maven with the -e switch
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 9 seconds
    [INFO] Finished at: Thu Jun 05 19:09:00 EDT 2008
    [INFO] Final Memory: 14M/25M
    [INFO] ------------------------------------------------------------------------
    
    C:\springwsmaven\holidayService>
    Here is my "pom.xml"
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.mycompany.hr</groupId>
        <artifactId>holidayService</artifactId>
        <packaging>war</packaging>
      <version>1.0-SNAPSHOT</version> 
        <name>holidayService Spring-WS Application</name>
        <url>http://www.springframework.org/spring-ws</url>
        <build>
            <finalName>holidayService</finalName>
        </build>
        <dependencies>
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-oxm</artifactId>
                <version>1.5.1</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.ws</groupId>
                <artifactId>spring-ws-core</artifactId>
                <version>1.5.1</version>
            </dependency>
    	    <dependency>
    	        <groupId>jdom</groupId>
    	        <artifactId>jdom</artifactId>
    	        <version>1.0</version>
    	    </dependency>
    	    <dependency>
    	        <groupId>jaxen</groupId>
    	        <artifactId>jaxen</artifactId>
    	        <version>1.1</version>
    	    </dependency>
    	    <dependency>
    	        <groupId>javax.xml.soap</groupId>
    	        <artifactId>saaj-api</artifactId>
    	        <version>1.3</version>
    	        <scope>runtime</scope>
    	    </dependency>
    	    <dependency>
    	        <groupId>com.sun.xml.messaging.saaj</groupId>
    	        <artifactId>saaj-impl</artifactId>
    	        <version>1.3</version>
    	        <scope>runtime</scope>
    	    </dependency>
          	<dependency>
    	      <groupId>javax.activation</groupId>
    	      <artifactId>activation</artifactId>
    	      <version>1.1</version>
    	    </dependency>
      </dependencies>
    </project>
    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>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>
    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">
    
    	<bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
    	    <property name="mappings">
    	        <props>
    	            <prop key="{http://mycompany.com/hr/schemas}HolidayRequest">holidayEndpoint</prop>
    	        </props>
    	    </property>
    	    <property name="interceptors">
    	        <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
    	    </property>
    	</bean>
    	
    	<bean id="holiday" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">   
    	    <property name="schema" ref="schema"/>                                               
    	    <property name="portTypeName" value="HumanResource"/>                                
    	    <property name="locationUri" value="http://localhost:8084/holidayService/"/>         
    	    <property name="targetNamespace" value="http://mycompany.com/hr/definitions"/>       
    	</bean>
    	
    	<bean id="schema" class="org.springframework.xml.xsd.SimpleXsdSchema">                   
    	    <property name="xsd" value="/WEB-INF/hr.xsd"/>
    	</bean>
    
    </beans>
    Here is my HolidayEndpoint.java file:
    Code:
    package com.mycompany.hr.ws;
    
    import java.text.SimpleDateFormat;
    import java.util.Date;
    
    import com.mycompany.hr.service.HumanResourceService;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.Namespace;
    import org.jdom.xpath.XPath;
    import org.springframework.ws.server.endpoint.AbstractJDomPayloadEndpoint;
    
    public class HolidayEndpoint extends AbstractJDomPayloadEndpoint {
    
        private XPath startDateExpression;
    
        private XPath endDateExpression;
    
        private XPath nameExpression;
    
        private final HumanResourceService humanResourceService;
    
        public HolidayEndpoint(HumanResourceService humanResourceService) {                  
            this.humanResourceService = humanResourceService;
            Namespace namespace = Namespace.getNamespace("hr", "http://mycompany.com/hr/schemas");
            startDateExpression = XPath.newInstance("//hr:StartDate");
            startDateExpression.addNamespace(namespace);
            endDateExpression = XPath.newInstance("//hr:EndDate");
            endDateExpression.addNamespace(namespace);
            nameExpression = XPath.newInstance("concat(//hr:FirstName,' ',//hr:LastName)");
            nameExpression.addNamespace(namespace);
        }
    
        protected Element invokeInternal(Element holidayRequest) throws Exception {          
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
            Date startDate = dateFormat.parse(startDateExpression.valueOf(holidayRequest));
            Date endDate = dateFormat.parse(endDateExpression.valueOf(holidayRequest));
            String name = nameExpression.valueOf(holidayRequest);
    
            humanResourceService.bookHoliday(startDate, endDate, name);
            return null;
        }
    }

    Here is my "hr.xsd" file
    Code:
    <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                      xmlns:schema="http://mycompany.com/hr/schemas"
                      xmlns:tns="http://mycompany.com/hr/definitions"
                      targetNamespace="http://mycompany.com/hr/definitions">
        <wsdl:types>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                <xsd:import namespace="http://mycompany.com/hr/schemas"                      
                    schemaLocation="hr.xsd"/>
            </xsd:schema>
        </wsdl:types>
        <wsdl:message name="HolidayRequest">                                                 
            <wsdl:part element="schema:HolidayRequest" name="HolidayRequest"/>               
        </wsdl:message>
        <wsdl:portType name="HumanResource">                                                 
            <wsdl:operation name="Holiday">
                <wsdl:input message="tns:HolidayRequest" name="HolidayRequest"/>             
            </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name="HumanResourceBinding" type="tns:HumanResource">                  
            <soap:binding style="document"                                                   
                transport="http://schemas.xmlsoap.org/soap/http"/>                           
            <wsdl:operation name="Holiday">
                <soap:operation soapAction="http://mycompany.com/RequestHoliday"/>           
                <wsdl:input name="HolidayRequest">
                    <soap:body use="literal"/>                                               
                </wsdl:input>
            </wsdl:operation>
        </wsdl:binding>
        <wsdl:service name="HumanResourceService">
            <wsdl:port binding="tns:HumanResourceBinding" name="HumanResourcePort">          
                <soap:address location="http://localhost:8084/holidayService/"/>             
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>
    Last edited by sairndain; Jun 5th, 2008 at 06:24 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •