Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Spring WS and SOAP UI

  1. #1
    Join Date
    May 2005
    Posts
    208

    Default 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. #2
    Join Date
    Dec 2005
    Posts
    24

    Default

    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

  3. #3
    Join Date
    May 2005
    Posts
    208

    Default

    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.

    %

  4. #4
    Join Date
    Dec 2005
    Posts
    24

    Default

    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.

  5. #5
    Join Date
    May 2005
    Posts
    208

    Default

    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."

    %

  6. #6
    Join Date
    May 2005
    Posts
    208

    Default

    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?

    %

  7. #7
    Join Date
    May 2005
    Posts
    208

    Default

    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?

    %

  8. #8
    Join Date
    May 2005
    Posts
    208

    Default

    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.

    %

  9. #9
    Join Date
    May 2005
    Posts
    208

    Default

    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.

    %

  10. #10
    Join Date
    May 2005
    Posts
    208

    Default

    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.

    %

Posting Permissions

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