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

  • Tutorial

    I've finally had the time to finish writing the tutorial for Spring-WS. It starts at http://static.springframework.org/sp...tutorial1.html (old stuff), an continues at http://static.springframework.org/sp...tutorial2.html (new stuff).

    Let me know what you think!

  • #2
    Thanks Arjen - it fills a gap. Martin.

    Comment


    • #3
      Thanks Arjen. It saves some time. I would update this page so others can find it. http://www.springframework.org/spring-ws

      Comment


      • #4
        Thanks, updated the site.

        Comment


        • #5
          org.springframework.oxm.jaxb.JaxbSystemException

          Hi Arjan,

          I am new to use all this stuff. I am just moving forward by reading the spring-ws tutorial. I am using Jaxb2Marshaller for marshalling and unmarshalling. All that I want to do is just Marshalling and Unmarshalling. I don't want to go through webservice stuff and all. Please see below what I have done so far.

          1. Downloaded JWSDP2.0 pack, which contains Jaxb2.0 and am added the jars (jaxb1-impl.jar,jaxb-api.jar,jaxb-impl.jar,jaxb-xjc.jar and the jars coming with spring-ws-1.0.1 release) into class path.
          2. Ran Jaxb Schemangen.bat against java file (Settings.java bean) for generating XSD file.
          3. After XSD generated, then I ran xjc.bat (Jaxb compiler) against this XSD file.
          4. Then it has generated two files: ObjectFactory.java and Settings.java in generated folder.
          5. Configured Jaxb2Marshaller in applicationContext as specified below.

          <bean id="application" class="testing.Application">
          <property name="marshaller" ref="jaxb2Marshaller" />
          <property name="unmarshaller" ref="jaxb2Marshaller" />
          </bean>

          <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshalle r">

          <property name="contextPath" value="generated">
          </property>
          </bean>

          Here, "generated" folder contains the java files ObjectFactory.java and Settings.java generated xjc compiler.

          6. Then I ran into two exceptions one after the other
          i. java.lang.NoClassDefFoundError: javax.activation.DataSource - I have added Activation.jar into class path to resolve this problem.
          ii. java.lang.NoClassDefFoundError: javax.xml.stream.XMLStreamException - I have added jsr173_1.0_api.jar into class path to resolve this problem.

          7. Now I am getting the following exception when it calls marshall method.
          org.springframework.oxm.jaxb.JaxbSystemException: Settings nor any of its super class is known to this context; nested exception is
          javax.xml.bind.JAXBException: Settings nor any of its super class is known to this context

          As I am spending lot of time so far in resolving the above exception, I thought of letting you know about this. I would be very happy if you can provide any clues/suggestions for resolving this error. Also, point me if am doing anything wrong here.

          Thanks,
          Ravi

          Comment


          • #6
            If you're just interested in Marshalling, refer to the corresponding chapter in the reference docs: http://static.springframework.org/sp.../html/oxm.html.

            In general, you need to configure JAXB with a contextPath. This is not the folder to which you generated the classes, but rather the Java package which contains the ObjectFactory and other files. Or you can set the classesToBeBound property (to Settings in your case).

            Comment


            • #7
              Marshalling and unMarshalling using Jaxb2Marshaller

              Thanks. Marshalling and unMarshalling using Jaxb2Marshaller works fine for me

              Comment


              • #8
                This is a great tutorial.. thanks for the work.

                Comment


                • #9
                  Tutorial Help

                  I have a problem in following the spring web service tutorial in the spring website (http://static.springframework.org/sp...tutorial2.html)

                  I could not execute the command in maven2
                  > mvn archetype:create -DarchetypeGroupId=org.springframework.ws \
                  -DarchetypeArtifactId=spring-ws-archetype \
                  -DarchetypeVersion=1.0-rc1-SNAPSHOT \
                  -DgroupId=com.mycompany.hr \
                  -DartifactId=holidayService

                  It returns an error “plugin … does not exist”

                  C:\>mvn archetype:create -DarchetypeGroupId=org.springframework.ws -DarchetypeArtifactId=spring-ws-archetype -DarchetypeVersion=1.0-rc1-SNAPSHOT -DgroupId=com.mycompany.hr -DartifactId=holidayService
                  [INFO] Scanning for projects...
                  [INFO] Searching repository for plugin with prefix: 'archetype'.
                  [INFO] ------------------------------------------------------------------------
                  [ERROR] BUILD ERROR
                  [INFO] ------------------------------------------------------------------------
                  [INFO] The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found
                  [INFO] ------------------------------------------------------------------------
                  [INFO] For more information, run Maven with the -e switch
                  [INFO] ------------------------------------------------------------------------
                  [INFO] Total time: < 1 second
                  [INFO] Finished at: Mon Oct 22 18:46:43 SGT 2007

                  I already deployed the maven 2.0.7; extracting the maven-2.0.7-bin.zip to . .. \Program Files\Apache Software Foundation\maven-2.0.7 (http://maven.apache.org/download.html) and updated my system variables.

                  I also downloaded maven-archetype-plugin-1.0-alpha-7.jar from the (http://repo1.maven.org/maven2/org/ap...n/1.0-alpha-7/) and copied it to my maven2\bin directory



                  I’m wondering if you could help me in using maven2 so that I could follow the tutorial.
                  or do you have a detailed walkthrough in how to install maven2? or another tutorial on how to start a spring web service project?

                  Thanks,

                  Comment


                  • #10
                    You might have a corrupted local repository. Remove ${HOME}/.m2/repository, and see it that works.

                    Comment


                    • #11
                      Tutorial Help

                      Thanks Arjen , i was able to finish the spring ws tutorial http://static.springframework.org/sp.../tutorial.html.

                      Here are the steps i did for those who have the same problem.
                      (“plugin … does not exist” error, maven could not download the files from the repo)

                      1. removed the ${HOME}/.m2/repository
                      2. edited my maven2 settings.xml, i added my proxy settings (wer using web proxy at the office)
                      3. executed "maven install" with error:
                      [ERROR] BUILD ERROR
                      [INFO] Failed to resolve artifact.
                      Missing:
                      ----------
                      1) javax.activation:activation:jar:1.0.2

                      4. downloaded activation jar version 1.0.2 and manually installed it
                      5. executed "maven install" again and the command created a new maven project

                      I have a new question though: HOW could i IMPORT the genereated project to ECLIPSE IDE?

                      Comment


                      • #12
                        Just run mvn eclipse:eclipse, that will create a project for you, which you can import into your workspace. See http://maven.apache.org/plugins/maven-eclipse-plugin/

                        Comment


                        • #13
                          soapAction=&quot;&quot;

                          Hi There,

                          After following
                          http://static.springframework.org/sp.../tutorial.html
                          and
                          http://static.springframework.org/sp...tutorial2.html

                          I managed to get http://localhost:8080/holidayService/holiday.wsdl generated. But inside the binding, soapAction=""
                          Code:
                          <?xml version="1.0" encoding="UTF-8" ?> 
                          - <wsdl:definitions xmlns:schema="http://mycompany.com/hr/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://mycompany.com/hr/definitions" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://mycompany.com/hr/definitions">
                          - <wsdl:types>
                          - <xs:schema xmlns:hr="http://mycompany.com/hr/schemas" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://mycompany.com/hr/schemas">
                          - <xs:element name="HolidayRequest">
                          - <xs:complexType>
                          - <xs:all>
                            <xs:element name="Holiday" type="hr:HolidayType" /> 
                            <xs:element name="Employee" type="hr:EmployeeType" /> 
                            </xs:all>
                            </xs:complexType>
                            </xs:element>
                          - <xs:complexType name="HolidayType">
                          - <xs:sequence>
                            <xs:element name="StartDate" type="xs:date" /> 
                            <xs:element name="EndDate" type="xs:date" /> 
                            </xs:sequence>
                            </xs:complexType>
                          - <xs:complexType name="EmployeeType">
                          - <xs:sequence>
                            <xs:element name="Number" type="xs:integer" /> 
                            <xs:element name="FirstName" type="xs:string" /> 
                            <xs:element name="LastName" type="xs:string" /> 
                            </xs:sequence>
                            </xs:complexType>
                            </xs: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="" /> - <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:8080/holidayService/" /> 
                            </wsdl:port>
                            </wsdl:service>
                            </wsdl:definitions>
                          Here is the hr.xsd
                          Code:
                          <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                  xmlns:hr="http://mycompany.com/hr/schemas"
                                  elementFormDefault="qualified"
                                  targetNamespace="http://mycompany.com/hr/schemas">
                              <xs:element name="HolidayRequest">
                                  <xs:complexType>
                                      <xs:all>
                                          <xs:element name="Holiday" type="hr:HolidayType"/>
                                          <xs:element name="Employee" type="hr:EmployeeType"/>
                                      </xs:all>
                                  </xs:complexType>
                              </xs:element>
                              <xs:complexType name="HolidayType">
                                  <xs:sequence>
                                      <xs:element name="StartDate" type="xs:date"/>
                                      <xs:element name="EndDate" type="xs:date"/>
                                  </xs:sequence>
                              </xs:complexType>
                              <xs:complexType name="EmployeeType">
                                  <xs:sequence>
                                      <xs:element name="Number" type="xs:integer"/>
                                      <xs:element name="FirstName" type="xs:string"/>
                                      <xs:element name="LastName" type="xs:string"/>
                                  </xs:sequence>
                              </xs:complexType>
                          </xs:schema>
                          Here is the 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 id="hrService" class="com.mycompany.hr.service.HumanResourceService"/>
                          	
                          	<bean id="holidayEndpoint" class="com.mycompany.hr.ws.HolidayEndpoint" init-method="init">
                          	    <constructor-arg ref="hrService"/>
                          	</bean>
                          
                          	<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.DynamicWsdl11Definition">
                          	    <property name="builder">
                          	        <bean class="org.springframework.ws.wsdl.wsdl11.builder.XsdBasedSoap11Wsdl4jDefinitionBuilder">
                          	            <property name="schema" value="/WEB-INF/hr.xsd"/>
                          	            <property name="portTypeName" value="HumanResource"/>
                          	            <property name="locationUri" value="http://localhost:8080/holidayService/"/>
                          	            <property name="targetNamespace" value="http://mycompany.com/hr/definitions"/>
                          	        </bean>
                          	    </property>
                          	</bean>
                          
                          </beans>
                          Any idea what could be missed?

                          Thanks
                          Last edited by jstone; Nov 19th, 2007, 11:25 PM.

                          Comment


                          • #14
                            re soap=&quot;&quot;

                            hey jstone,

                            i have the same wsdl as you do and it is working just fine with me

                            ....
                            <soap:operation soapAction=""/>
                            <wsdl:input name="HolidayRequest">
                            <soap:body use="literal"/>
                            </wsdl:input>
                            ....
                            have you tried testing it? log the name, age, date, etc and try using soapUI v1.7.6 as a sample client to consume your web service

                            or are you referring to the sample wsdl that is in the tutorial?, then yes it is different and i dont know y it still works.

                            Comment


                            • #15
                              Hey Opinioag,

                              Thanks for the heads-up. Yeah, I was expecting
                              <soap:operation soapAction="http://mycompany.com/RequestHoliday"/>
                              to show up as being described in Chapter 3
                              http://static.springframework.org/sp.../tutorial.html

                              I tried soapUI and it works well with another sample code (echoservice) that I was playing around. But it seems to have type problem with "date" in holiday service. I fed in
                              Code:
                              <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://mycompany.com/hr/schemas">
                                 <soapenv:Header/>
                                 <soapenv:Body>
                                    <sch:HolidayRequest>
                                       <sch:Holiday>
                                          <sch:StartDate>2007-06-10</sch:StartDate>
                                          <sch:EndDate>2007-09-20</sch:EndDate>
                                       </sch:Holiday>
                                       <sch:Employee>
                                          <sch:Number>1</sch:Number>
                                          <sch:FirstName>Hi</sch:FirstName>
                                          <sch:LastName>There</sch:LastName>
                                       </sch:Employee>
                                    </sch:HolidayRequest>
                                 </soapenv:Body>
                              </soapenv:Envelope>
                              And I saw the error in soapUI reads like
                              Code:
                              <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
                                 <SOAP-ENV:Header/>
                                 <SOAP-ENV:Body>
                                    <SOAP-ENV:Fault>
                                       <faultcode>SOAP-ENV:Server</faultcode>
                                       <faultstring xml:lang="en">Unparseable date: ""</faultstring>      </SOAP-ENV:Fault>
                                 </SOAP-ENV:Body>
                              </SOAP-ENV:Envelope>
                              Any idea how to fix it?

                              Thanks in advance!

                              Comment

                              Working...
                              X