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

Thread: Help required, spring ws communicate with jsp

  1. #1
    Join Date
    Apr 2009
    Posts
    10

    Default Help required, spring ws communicate with jsp

    Hi;

    Using Spring WS for the first time, i wrote my web service, i test my wsdl with eclipse plugin also with SoapUI and it works perfectly.
    In my xsd, i have data like id, first name and last name, when i call my service, it insert the data that i fill in my database.

    Now i would like to communicate with jsp pages, i mean when i try to test my service, a jsp page will appear with the element, that i put in xsd file (id,first name,last name) and when i click in th button it will call my service and insert the data in the database.

    Coud anyone help me please??

  2. #2
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    I'm trying to figure out exactly what you're trying to do.

    When you say "communicate with jsp pages", i would assume you intend to have the code implementing the web service make an HTTP connection to a URL which is implemented on some server with a JSP page, and then have the service parse the HTML (XML?) returned from that HTTP connection and then do something with it. Typically, this would use Apache Commons HttpClient to make the connection. Depending on the content you intend to get back, there are different choices for handling the response.

    Then, you say "a jsp page will appear with the element". I have no idea what that means.

  3. #3
    Join Date
    Apr 2009
    Posts
    10

    Default

    Thank u for replying.
    i will put a screen shot to explain what i mean.
    when i test my wsdl with eclipse i got this page "wsdl.gif", what i would like to do is to get the same page but not with eclipse plugin, but a jsp page, or whatever.
    Attached Images Attached Images

  4. #4
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    In other words, you need to write a web service client. Typically, you would write web service client code in a back-end service or web controller, not in a JSP. You would then take the results from the web service and put it into context variables that can then be referenced by a JSP that you forward to. This web service client code can use the Spring-WS framework (read the Spring-WS doc for more info), or it can use JAX-WS, or several other frameworks, even including Apache Commons HttpClient sending raw SOAP message text.

  5. #5
    Join Date
    Apr 2009
    Posts
    10

    Default

    Thank u so much, that is exactly what i mean.
    can u advice me on what kind of web service client to use, considering that i don't have too much time to do it (1 week)
    also, do u have an example or could you give me some links that can help me.

    Thank u

  6. #6
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    As you're already using Spring-WS, just use that. Read the main Spring-WS reference manual at http://static.springsource.org/sprin...reference.html

  7. #7
    Join Date
    Apr 2009
    Posts
    10

    Default

    hi, as u advice me, i wrote a client spring-ws
    Code:
    package client;
    import java.io.IOException;
    
    
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
    
    import org.springframework.core.io.ClassPathResource;
    import org.springframework.core.io.Resource;
    
    import org.springframework.ws.client.core.WebServiceTemplate;
    
    
    public class WebServiceClient {
    
    
        Resource resource = new ClassPathResource("/client/RechercheRequest.xml");
    
    
        private final WebServiceTemplate webServiceTemplate = new WebServiceTemplate(); 
     
        
        
    //    StreamSource source = new StreamSource(resource.getInputStream());
    //    StreamResult result = new StreamResult(System.out);
    
        public void simpleSendAndReceive() throws IOException {
            StreamSource source = new StreamSource(resource.getInputStream());
            StreamResult result = new StreamResult(System.out);
           
            webServiceTemplate.sendSourceAndReceiveToResult("http://localhost:8080/spring-wsTest/rechercherLangueService/",source, result);
            System.out.println(result.toString());
        }
    
       public static void main(String[] args) throws IOException {
    	  
    	   WebServiceClient webServiceClient =new WebServiceClient();
    	   webServiceClient.simpleSendAndReceive();
    		
    	}
      
    
    }
    i think that's ok, i make some test in my endpoint with System.out.println() and i got the result, but the problem is that in the console, it doesn't display it.
    Could u help me?

  8. #8
    Join Date
    May 2009
    Posts
    5

    Default

    Hi,
    I have the same problem of the web service client,
    So in the file rechercheRequest.xml what did you write??

    Thanks

  9. #9
    Join Date
    Jan 2006
    Location
    Seattle, Washington
    Posts
    467

    Default

    I would run both your web container and your standalone client in debug sessions in Eclipse (or whatever debugger you're using) and step through the code. Especially watch the result produced by your service, and the "result" object you get back.

  10. #10

    Default

    chk this articel might be it will be helpful to you ..
    http://springkbase.blogspot.com/2009...th-castor.html

Posting Permissions

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