Announcement Announcement Module
Collapse
No announcement yet.
How to test the Echo sample? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to test the Echo sample?

    This is probably going to be silly, but how do you run the Echo sample app?

    I have it cleanly war'd and deployed to tomcat, i.e. I see the:

    Spring-WS Echo
    If you see this page, the WAR deployment was successful.

    ...but I don't see a main method (in, say, EchoEndpointTest.java) or a jsp with which to kick off a test.

    Ben

  • #2
    Hi Ben,

    there isn't any client.
    You can use the "Web Service Explorer" from Eclipse (WTP) to test it.
    Or you create your own client from the wsdl (JWSDP,Axis,XFire,...).

    Cheers,

    Ingo

    Comment


    • #3
      Thanks.

      If I fire up the Web Services Explorer in Eclipse, it wants to know about the uddi registry. (I've never used that one before, but am prett familiar with most of Eclipse.) I don't quite see how to test Echo there yet. Can you show me the way?

      I'm used to "injecting" Axis into my deployed app in Tomcat, such that I can then see the WSDL, if I go to the url, say:

      http://localhost:8080/myApp/services...ndingPort?wsdl

      ...but when I do that with the echo app:

      http://localhost:8080/echo/services

      ...which is from your wsdl here:

      <wsdl:service name="TestService">
      <wsdlort binding="tns:TestServiceHttpBinding" name="TestServiceHttpPort">
      <wsdlsoap:address location="http://localhost:8080/echo/services"/>
      </wsdlort>
      </wsdl:service>

      ....I get a blank screen. Same blank screen if I try:

      http://localhost:8080/echo/services?wsdl

      The tomcat startup looks clean, and when I do the above, just shows:

      2006-06-22 11:38:31,401 INFO [org.springframework.ws.transport.http.MessageHandl
      erAdapter] - Using message context factory org.springframework.ws.soap.saaj.Saaj
      SoapMessageContextFactory@1e6f0ef


      ...which looks reasonable.

      I've read through the spring-ws-core-reference.pdf, but I don't yet see how to fully deploy and test a simple Spring Web Service.

      Am I missing something in the documentation? or ?

      Ben

      Comment


      • #4
        Originally posted by benethridge
        I'm used to "injecting" Axis into my deployed app in Tomcat, such that I can then see the WSDL, if I go to the url, say:

        http://localhost:8080/myApp/services...ndingPort?wsdl

        ...but when I do that with the echo app:

        http://localhost:8080/echo/services

        ...which is from your wsdl here:

        <wsdl:service name="TestService">
        <wsdlort binding="tns:TestServiceHttpBinding" name="TestServiceHttpPort">
        <wsdlsoap:address location="http://localhost:8080/echo/services"/>
        </wsdlort>
        </wsdl:service>

        ....I get a blank screen. Same blank screen if I try:

        http://localhost:8080/echo/services?wsdl

        The tomcat startup looks clean, and when I do the above, just shows:

        2006-06-22 11:38:31,401 INFO [org.springframework.ws.transport.http.MessageHandl
        erAdapter] - Using message context factory org.springframework.ws.soap.saaj.Saaj
        SoapMessageContextFactory@1e6f0ef


        ...which looks reasonable.
        Spring-WS doesn not automatically generate or publish the WSDL document under services/something?wsdl, because it is based on contract-first development: you write the WSDL yourself. Therefore, the WSDL is just a plain file in the war. If you look in the war, you will find an echo.wsdl, which you can point your client at using http://localhost:8080/echo/echo.wsdl. It's just a file, after all :-).

        Originally posted by benethridge
        I've read through the spring-ws-core-reference.pdf, but I don't yet see how to fully deploy and test a simple Spring Web Service.

        Am I missing something in the documentation? or ?
        It could be you are missing information in the documentation, because the documentation is still in progress. I'm mostly focussing on the WS-security chapter now, because that is what people have the most questions about, but I hope to finish the other chapter (about the core WS functionality) soon.

        Cheers,

        Comment


        • #5
          If I fire up the Web Services Explorer in Eclipse, it wants to know about the uddi registry. (I've never used that one before, but am prett familiar with most of Eclipse.) I don't quite see how to test Echo there yet. Can you show me the way?
          On the top right bar are six buttons. Click on "wsdl page" and choose the one from the project. Now you can test the web servicee.

          The Web Service Explorer has a (already reported) bug. In my case, i have to deactivate the internet/proxy settings.

          Cheers,

          Ingo

          Comment


          • #6
            Thanks, Ingo (and you too, Argen).

            I see that now. I think the missing piece is that I deployed the Echo "project" straight from java, with your build.xml, which made a war that I deployed straight into tomcat, i.e. I bypassed Eclipse coz I couldn't figure out how to import it into Eclipse

            Can you tell me the best way to import it into Eclipse? I've tried a couple of ways (including attempting to import the generated echo.war), but nothing has lined up cleanly yet. (I have Eclipse 3.1.x)

            Ben

            Comment


            • #7
              FWIW: Here is a simple test client I wrote for the Echo project. I just cloned/morphed the client from the Airline project:

              Code:
              /*
               * Copyright (c) 2006, Your Corporation. All Rights Reserved.
               * Copyright 2006 the original author or authors.
               *
               * Licensed under the Apache License, Version 2.0 (the "License");
               * you may not use this file except in compliance with the License.
               * You may obtain a copy of the License at
               *
               *      http://www.apache.org/licenses/LICENSE-2.0
               *
               * Unless required by applicable law or agreed to in writing, software
               * distributed under the License is distributed on an "AS IS" BASIS,
               * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
               * See the License for the specific language governing permissions and
               * limitations under the License.
               */
              
              package org.springframework.ws.samples.echo.client.saaj;
              
              import java.io.IOException;
              import java.net.MalformedURLException;
              import java.net.URL;
              
              import javax.xml.soap.MessageFactory;
              import javax.xml.soap.Name;
              import javax.xml.soap.SOAPBodyElement;
              import javax.xml.soap.SOAPConnection;
              import javax.xml.soap.SOAPConnectionFactory;
              import javax.xml.soap.SOAPEnvelope;
              import javax.xml.soap.SOAPException;
              import javax.xml.soap.SOAPFault;
              import javax.xml.soap.SOAPMessage;
              import javax.xml.transform.TransformerException;
              import javax.xml.transform.TransformerFactory;
              
              public class EchoClient {
              
              	public static final String NAMESPACE_URI = "http://www.springframework.org/spring-ws/samples/echo";
              
              	public static final String PREFIX = "tns";
              
              	private SOAPConnectionFactory connectionFactory;
              
              	private MessageFactory messageFactory;
              
              	private URL url;
              
              	private TransformerFactory transfomerFactory;
              
              	public EchoClient(String url) throws SOAPException,
              			MalformedURLException {
              		connectionFactory = SOAPConnectionFactory.newInstance();
              		messageFactory = MessageFactory.newInstance();
              		transfomerFactory = TransformerFactory.newInstance();
              		this.url = new URL(url);
              	}
              
              	private SOAPMessage createEchoRequest() throws SOAPException {
              		SOAPMessage message = messageFactory.createMessage();
              		SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
              		Name echoRequestName = envelope.createName("echoRequest", PREFIX,
              				NAMESPACE_URI);
              		SOAPBodyElement echoRequestElement = message.getSOAPBody()
              				.addBodyElement(echoRequestName);
              		echoRequestElement.setValue("HelloBen");
              		return message;
              	}
              
              	public void callWebService() throws SOAPException, IOException,
              			TransformerException {
              		SOAPMessage request = createEchoRequest();
              		SOAPConnection connection = connectionFactory.createConnection();
              		SOAPMessage response = connection.call(request, url);
              		if (!response.getSOAPBody().hasFault()) {
              			writeEchoResponse(response);
              		} else {
              			SOAPFault fault = response.getSOAPBody().getFault();
              			System.err.println("Received SOAP Fault");
              			System.err.println("SOAP Fault Code :" + fault.getFaultCode());
              			System.err.println("SOAP Fault String :" + fault.getFaultString());
              		}
              	}
              
              	private void writeEchoResponse(SOAPMessage message) throws SOAPException,
              			TransformerException {
              		SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
              		Name echoResponseName = envelope.createName("echoResponse", PREFIX,
              				NAMESPACE_URI);
              		SOAPBodyElement echoResponseElement = (SOAPBodyElement) message
              				.getSOAPBody().getChildElements(echoResponseName).next();
              		String echoValue = echoResponseElement.getTextContent();
              		System.out.println("Echo Value: " + echoValue);
              	}
              
              	public static void main(String[] args) throws Exception {
              		String url = "http://localhost:8080/echo/services";
              		if (args.length > 0) {
              			url = args[0];
              		}
              		EchoClient echoClient = new EchoClient(url);
              		echoClient.callWebService();
              	}
              }

              Comment


              • #8
                Hi,

                Probs a silly question but what Jar files are required in order to get the above SOAP Client to work. Do I require Axis jars or another implementation of saaj?

                Thanks,

                J

                Comment


                • #9
                  They would be the following:

                  saaj-api.jar
                  saaj-impl.jar
                  mail.jar
                  activation.jar
                  xercesImpl.jar

                  You can get them from the echo project or the airline project.

                  I discovered which ones were needed, by creating a simple Java "echoclient" project, and then (as usual in java) building it, and seeing what it was missing, and then running it, and seeing which classes were not found.

                  I wish there were a better way to do this in java, as I've never enjoyed this part of the process, and it seems so unreliable coz you have to discover them at run-time instead of compile-time. Is there a better way?

                  Ben

                  Comment


                  • #10
                    I've created a JIRA issue for the Echo client http://opensource.atlassian.com/proj.../browse/SWS-41. I will add it soon, if you (Ben), allow me to include your code to the SWS codebase. You already "released" it under the Apache license, so I don't think this will be a problem, but I'm asking just to be sure.

                    Thanks,

                    Comment


                    • #11
                      Yes. Glad I could help with this. Feel free to use and modify the code as you deem appropriate.

                      Ben

                      Comment


                      • #12
                        Hi Ben,

                        Thanks for the Jar info. That seemed to do the trick. I also perform a build/find scenario when trying to figure out jars. If anyone has a better strat I would be really interested to hear it.

                        Cheers,

                        J

                        Comment


                        • #13
                          help running test echo client

                          Hi I've been trying to run the test client as posted above however, I get a Soap fault complaining "UndeclaredPrefix: Cannot resolve 'soapenc:string' as a QName: the prefix 'soapenc' is not declared." The code is pretty much a cut and paste from the post and deployed from the ant compiled war, so i really haven't made any changes. I've tried adding the definitions to the xsd file, but it doesn't seem to make any difference. Anyone have any ideas?

                          Comment


                          • #14
                            SOAP Fault, more info

                            Again, still trying to get the echo service to work properly...I am relatively new to this stuff...any help would be appreciated.

                            Running the echo client, the SOAP request comes out to be:

                            <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                            <tns:echoRequest xsi:type="xsd:string"
                            xmlns:tns="http://www.springframework.org/spring-ws/samples/echo"
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                            HelloBen</tns:echoRequest>
                            </soapenv:Body>


                            Yielding an error:

                            <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><s
                            oapenv:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Validation error
                            </faultstring><detail><spring-ws:ValidationError xmlns:spring-ws="http://springf
                            ramework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'soapenc:string' as a Q
                            Name: the prefix 'soapenc' is not declared.</spring-ws:ValidationError><spring-w
                            s:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">Undecla
                            redPrefix: Cannot resolve 'soapenc:string' as a QName: the prefix 'soapenc' is n
                            ot declared.</spring-ws:ValidationError><spring-ws:ValidationError xmlns:spring-
                            ws="http://springframework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'soap
                            enc:string' as a QName: the prefix 'soapenc' is not declared.</spring-ws:Validat
                            ionError><spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/
                            spring-ws">UndeclaredPrefix: Cannot resolve 'soapenc:string' as a QName: the pre
                            fix 'soapenc' is not declared.</spring-ws:ValidationError></detail></soapenv:Fau
                            lt></soapenv:Body>



                            When I run a request off the Eclipse Webservice Explorer, the request comes out to be:

                            <?xml version="1.0" encoding="UTF-8" ?>
                            <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                            <soapenv:Body>
                            <echoString>test</echoString>
                            </soapenv:Body>
                            </soapenv:Envelope>


                            yielding a different error:

                            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
                            <SOAP-ENV:Header />
                            - <SOAP-ENV:Body>
                            - <SOAP-ENV:Fault>
                            <faultcode>SOAP-ENV:Client</faultcode>
                            <faultstring>Validation error</faultstring>
                            - <detail>
                            <spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">cvc-elt.1: Cannot find the declaration of element 'echoString'.</spring-ws:ValidationError>
                            </detail>
                            </SOAP-ENV:Fault>
                            </SOAP-ENV:Body>
                            </SOAP-ENV:Envelope>


                            any input would be apprecited!

                            Comment


                            • #15
                              Originally posted by sjan
                              Again, still trying to get the echo service to work properly...I am relatively new to this stuff...any help would be appreciated.

                              Running the echo client, the SOAP request comes out to be:

                              <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                              <tns:echoRequest xsi:type="xsd:string"
                              xmlns:tns="http://www.springframework.org/spring-ws/samples/echo"
                              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                              xmlns:xsd="http://www.w3.org/2001/XMLSchema">
                              HelloBen</tns:echoRequest>
                              </soapenv:Body>


                              Yielding an error:

                              <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><s
                              oapenv:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Validation error
                              </faultstring><detail><spring-ws:ValidationError xmlns:spring-ws="http://springf
                              ramework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'soapenc:string' as a Q
                              Name: the prefix 'soapenc' is not declared.</spring-ws:ValidationError><spring-w
                              s:ValidationError xmlns:spring-ws="http://springframework.org/spring-ws">Undecla
                              redPrefix: Cannot resolve 'soapenc:string' as a QName: the prefix 'soapenc' is n
                              ot declared.</spring-ws:ValidationError><spring-ws:ValidationError xmlns:spring-
                              ws="http://springframework.org/spring-ws">UndeclaredPrefix: Cannot resolve 'soap
                              enc:string' as a QName: the prefix 'soapenc' is not declared.</spring-ws:Validat
                              ionError><spring-ws:ValidationError xmlns:spring-ws="http://springframework.org/
                              spring-ws">UndeclaredPrefix: Cannot resolve 'soapenc:string' as a QName: the pre
                              fix 'soapenc' is not declared.</spring-ws:ValidationError></detail></soapenv:Fau
                              lt></soapenv:Body>
                              You posted the body, but not the complete message, so it's kinda hard for me to figure out. It seems that somewhere, a reference to soapenc:string is made, otherwise the validator wouldn't complain about it. However, i don't see that reference.

                              You can write the entire message on a SOAPMessage object by calling writeTo(System.out), or something similar.

                              Comment

                              Working...
                              X