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

  • Spring WS and SOAP UI

    I wrote a contract first web service using Spring 2.5.4, Spring WS 1.5.2, deployed on WebLogic 8.1.6 under JDK 1.4.2_11. When I bring up WebLogic, I can get WSDL showing up in my browser.

    I'd like to use SOAP UI 2.0.2 to generate a client and test out my service, but I'm afraid that I missed something important. I can start SOAP UI, open a new project, and point it at my WSDL. All is well, but there are no operations to test.

    What did I miss? I have an XSD describing an XML stream that I'd like to send, but I can't figure out how to generate the client. Can somebody short circuit the tutorial and explain it to me? Thanks - %

  • #2
    Can you post the schema you are using? It's probably the name of the request and response element. Each one need to have Request or Response in the name

    Comment


    • #3
      Hi Steve,

      No Request or Response in any of my tags, which might explain it. I just fired up SOAP UI without reading a thing. We don't need no stinkin' documentation!

      Worse problems yesterday afternoon. Got everything working just fine, seeing WSDL in the browser. When I struck out with SOAP UI I started writing my own test client using Spring classes. Too bad I was using WL 8.1.6 and JDK 1.4.2_11. When I ran the client I got one of those major.minor version exceptions. I'll have to see what JARs I need to replace to get this to work.

      %

      Comment


      • #4
        Mike, Spring ws uses a naming convention to create methods in the soap wsdl, requests need to have Request in the appended to the tag name and if there is a response then there needs to be a tag with the same name appended with Response. It used to be in the documentation for the tutorial but I can't seem to find it.

        Comment


        • #5
          Thanks Steve, I think that's exactly what I'm missing.

          I just imported some WSDL from GoogleSearch, and I can see the operations in SOAP UI. I'm going to look at their WSDL to see what is missing from mine.

          My contract first approach followed the Spring WS faithfully. If I can tease out a solution to my problem, perhaps I'll offer a modification to the tutorial. I think it would be helpful to show the SOAP UI interaction at the end instead of leaving it as "...and the proof is left for the student."

          %

          Comment


          • #6
            Once again my ignorance is exposed. I started combing through the SOAPUI docs and found a link to the W3C schools WSDL tutorial:

            http://www.w3schools.com/wsdl/wsdl_documents.asp

            My generated WSDL is missing the <message> tags. They've got request and response definitions. How do I tell Spring to generate them for me?

            %

            Comment


            • #7
              If I look at the HolidayRequest tutorial, the hand-written WSDL has a <message> in it. The Spring generated WSDL does not, as far as I can tell. What did I miss?

              %

              Comment


              • #8
                Progress: adding the requestSuffix and responseSuffix properties in my DefaultWsdl11Definition configuration got me a message in my WSDL.

                Next step: persuade SOAPUI to help me with some test cases. When I right click on the SOAPUI workspace and select "Launch Test Runner", I get a dialog box with a "java.lang.NullPointerException" as the message. I must not have TestRunner configured properly. Stay tuned.

                %

                Comment


                • #9
                  Progress: Now I can generate an XML request and fill in my data values.

                  Problem: I'm running in debug mode with breakpoints set in my endpoint constructor and invokeInternal methods.

                  I stop in the constructor, and I can see that my XPath data members are set.

                  When I submit the XML request to the service I never stop in the "invokeInternal" method. I should see the values from the XML stream persisted in a database, but the method is never called.

                  %

                  Comment


                  • #10
                    More info:

                    If I send this SOAP message:

                    Code:
                    Host: localhost:7001
                    Content-Length: 493
                    SOAPAction: ""
                    User-Agent: Jakarta Commons-HttpClient/3.0.1
                    Content-Type: text/xml;charset=UTF-8
                    
                    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://com.hlikk.ingenium/machi/schemas">
                       <soapenv:Header/>
                       <soapenv:Body>
                          <sch:MACHI_RESTRICT_DATA_REQUEST>
                             <sch:MSG_ID>12345678</sch:MSG_ID>
                             <sch:POLICY_ID>12345678</sch:POLICY_ID>
                             <sch:USER_ID>duffymo</sch:USER_ID>
                             <sch:MACHI_RESTRICT_IND>Y</sch:MACHI_RESTRICT_IND>
                          </sch:MACHI_RESTRICT_DATA_REQUEST>
                       </soapenv:Body>
                    </soapenv:Envelope>
                    I'm getting an HTTP 404 "Not Found" as the response.

                    My Endpoint code looks like this:

                    Code:
                    /**
                     * Spring "contract first" web service for Restriction.
                     * Payload endpoint does NOT have access to SOAP headers,
                     * only the contents of the SOAP body.
                     * Date: May 30, 2008
                     * Time: 10:16:28 AM
                     * @link http://static.springframework.org/spring-ws/site/reference/html/tutorial.html
                     */
                    public class RestrictionEndpoint extends AbstractJDomPayloadEndpoint
                    {
                       private XPath policyIdExpression;
                       private XPath updatedByUserIdExpression;
                       private XPath restrictedExpression;
                    
                       private RestrictionService restrictionService;
                       private static final String DEFAULT_NAMESPACE = "sch";
                    
                       public RestrictionEndpoint(RestrictionService restrictionService) throws JDOMException
                       {
                          this.restrictionService = restrictionService;
                    
                          policyIdExpression = XPath.newInstance("//POLICY_ID");
                          updatedByUserIdExpression = XPath.newInstance("//USER_ID");
                          restrictedExpression = XPath.newInstance("//MACHI_RESTRICT_IND");
                    
                          // TODO: Add Namespace if necessary
                    /*
                          Namespace namespace = Namespace.getNamespace(DEFAULT_NAMESPACE);
                          policyIdExpression.addNamespace(namespace);
                          updatedByUserIdExpression.addNamespace(namespace);
                          restrictedExpression.addNamespace(namespace);
                    */
                       }
                    
                       protected Element invokeInternal(Element restrictionRequest) throws Exception
                       {
                          String policyId = policyIdExpression.valueOf(restrictionRequest);
                          String updatedByUserId = updatedByUserIdExpression.valueOf(restrictionRequest);
                          String restrictedStr = restrictedExpression.valueOf(restrictionRequest);
                    
                          boolean restricted = fromYesNoToBoolean(restrictedStr);
                    
                          Restriction restriction = new Restriction(policyId, updatedByUserId, restricted);
                    
                          restrictionService.saveOrUpdate(restriction);
                    
                          return null;
                       }
                    
                       private boolean fromYesNoToBoolean(String restrictedStr)
                       {
                          boolean value = false;
                    
                          if (restrictedStr.length() > 0)
                          {
                             char firstChar = restrictedStr.charAt(0);
                    
                             value = ((firstChar == 'Y') || (firstChar == 'y')); 
                          }
                    
                          return value;
                       }
                    }
                    As you can see, I have the Namespace addition commented out. If I uncomment the Namespace lines in the constructor, I get a new response: HTTP 503 "service unavailable".

                    I still don't understand exactly what's going on. Stay tuned. Still digging.

                    %

                    Comment


                    • #11
                      Looking in the WebLogic console after submitting my request, I see these messages:

                      Code:
                      02 Jun 2008 13:20:24 DEBUG received - Received request [SaajSoapMessage {http://com.hlikk.ingenium/machi/schemas}MACHI_RESTRICT_DATA_REQUEST]
                      02 Jun 2008 13:20:24 DEBUG PayloadRootQNameEndpointMapping - Looking up endpoint for [{http://com.hlikk.ingenium/machi/schemas}MACHI_RESTRICT_DATA_REQUEST]
                      02 Jun 2008 13:20:24 DEBUG SoapMessageDispatcher - Endpoint mapping [org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping@6597d1] has no mapping for request
                      02 Jun 2008 13:20:24  WARN EndpointNotFound - No endpoint mapping found for [SaajSoapMessage {http://com.hlikk.ingenium/machi/schemas}MACHI_RESTRICT_DATA_REQUEST]
                      02 Jun 2008 13:20:24 DEBUG MessageDispatcherServlet - Successfully completed request
                      Why no mapping? My config isn't correct, but I'm not seeing it.

                      Here's my Spring app context for the service:

                      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:aop="http://www.springframework.org/schema/aop"
                             xmlns:tx="http://www.springframework.org/schema/tx"
                             xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                             http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
                      
                         <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
                            <property name="sessionFactory" ref="sessionFactory"/>
                         </bean>
                      
                         <bean id="restrictionService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
                            <property name="transactionManager" ref="transactionManager"/>
                            <property name="target" ref="restrictionServiceTarget"/>
                            <property name="transactionAttributes">
                               <props>
                                  <prop key="find*">PROPAGATION_REQUIRED, readOnly</prop>
                                  <prop key="save*">PROPAGATION_REQUIRED</prop>
                                  <prop key="*">PROPAGATION_REQUIRED, readOnly</prop>
                               </props>
                            </property>
                         </bean>
                      
                         <bean id="restrictionServiceTarget" class="com.hlikk.ingenium.service.RestrictionServiceImpl">
                            <constructor-arg ref="restrictionDao"/>
                         </bean>
                      
                         <bean id="restrictionEndpoint" class="com.hlikk.ingenium.ws.RestrictionEndpoint">
                            <constructor-arg ref="restrictionService"/>
                         </bean>
                         
                         <bean class="org.springframework.ws.server.endpoint.mapping.PayloadRootQNameEndpointMapping">
                            <property name="mappings">
                               <props>
                                  <prop key="{http://com.hlikk.ingenium/machi/schemas}RestrictionRequest">restrictionEndpoint</prop>
                               </props>
                            </property>
                            <property name="interceptors">
                               <bean class="org.springframework.ws.server.endpoint.interceptor.PayloadLoggingInterceptor"/>
                            </property>
                         </bean>
                      
                         <bean id="restrictionSchema" class="org.springframework.xml.xsd.SimpleXsdSchema">
                            <property name="xsd" value="/WEB-INF/schemas/machi-restrict-data-request.xsd"/>
                         </bean>
                      
                         <bean id="restriction" class="org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition">
                            <property name="requestSuffix" value="_REQUEST"/>
                            <property name="schema" ref="restrictionSchema"/>
                            <property name="portTypeName" value="${restriction.port}"/>
                            <property name="locationUri" value="${restriction.uri}"/>
                            <property name="targetNamespace" value="${restriction.namespace"/>
                         </bean>
                      
                      </beans>
                      %

                      Comment


                      • #12
                        Is it the brace in the key?

                        Code:
                              <property name="mappings">
                                 <props>
                                    <prop key="{

                        Comment


                        • #13
                          Yes:

                          Code:
                                      <prop key="{http://com.hlikk.ingenium/machi/schemas}RestrictionRequest">restrictionEndpoint</prop>
                          That's the way it appears in the HolidayRequest tutorial.

                          %

                          Comment


                          • #14
                            More progress: I had the wrong key in my Spring configuration.

                            Was:

                            Code:
                            <prop key="{http://com.hlikk.ingenium/machi/schemas}RestrictionRequest">restrictionEndpoint</prop>
                            Should be:

                            Code:
                            <prop key="{http://com.hlikk.ingenium/machi/schemas}MACHI_RESTRICT_DATA_REQUEST">restrictionEndpoint</prop>
                            The root tag of my XML stream was incorrect.

                            Now I can see that my endpoint is being mapped and invoked properly, but I've got another issue regarding namespaces. Stay tuned.

                            %

                            Comment


                            • #15
                              Glad to hear that there is progress. That's probably a weblogic issue, I encountered that before with using weblogic implementation.
                              Last edited by sroach; Jun 2nd, 2008, 05:37 PM.

                              Comment

                              Working...
                              X