Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: How to test the Echo sample?

  1. #1
    Join Date
    Feb 2006
    Posts
    164

    Default 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. #2
    Join Date
    Mar 2006
    Location
    Germany, Karlsruhe
    Posts
    157

    Default

    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

  3. #3
    Join Date
    Feb 2006
    Posts
    164

    Default

    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

  4. #4
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    Quote 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 :-).

    Quote 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,
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

  5. #5
    Join Date
    Mar 2006
    Location
    Germany, Karlsruhe
    Posts
    157

    Default

    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

  6. #6
    Join Date
    Feb 2006
    Posts
    164

    Default

    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

  7. #7
    Join Date
    Feb 2006
    Posts
    164

    Default

    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();
    	}
    }

  8. #8

    Default

    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

  9. #9
    Join Date
    Feb 2006
    Posts
    164

    Default

    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

  10. #10
    Join Date
    Jul 2005
    Location
    Rotterdam, the Netherlands
    Posts
    1,562

    Default

    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,
    Arjen Poutsma

    Spring Web Services Dev Lead
    Please read the FAQ

Posting Permissions

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