web services - Java Webservices using jax-ws -


web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="webapp_id" version="2.5"> <display-name>ws</display-name>  <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener>  <listener>     <listener-class>         com.sun.xml.ws.transport.http.servlet.wsservletcontextlistener     </listener-class> </listener>  <servlet>     <servlet-name>sayhello</servlet-name>     <servlet-class>         com.sun.xml.ws.transport.http.servlet.wsservlet     </servlet-class>    <load-on-startup>1</load-on-startup> </servlet>  <servlet-mapping>     <servlet-name>sayhello</servlet-name>     <url-pattern>/ws</url-pattern> </servlet-mapping>  <session-config>     <session-timeout>30</session-timeout> </session-config> </web-app> 

sun-jaxws.xml

<?xml version="1.0" encoding="utf-8"?> <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">     <endpoint             name="mywsendpoint"             implementation="com.test.ws.mywsendpoint"             url-pattern="/ws"/> </endpoints> 

mywsendpoint.java

package com.test.ws;  import javax.jws.webmethod; import javax.jws.webservice;  import org.springframework.beans.factory.annotation.autowired; import org.springframework.web.context.support.springbeanautowiringsupport;  @webservice(targetnamespace = "http://my.ws/myws",         portname = "mywsservice",         servicename = "myws",         endpointinterface = "com.test.ws.mywsservice")  public class mywsendpoint extends springbeanautowiringsupport implements mywsservice {      @autowired     private mywsservice proxy;       @override       @webmethod()     public string getname(string name) {         string a=proxy.getname("john");         return a;     }  } 

mywsservice.java

package com.test.ws;  import javax.jws.webservice; @webservice public interface mywsservice {     public string getname(string name); } 

helloimpl.java

package com.test.ws;  import javax.jws.webservice; @webservice(endpointinterface = "com.test.ws.mywsservice") public class helloimpl implements  mywsservice{      @override     public string getname(string name) {         string s=name;         return s;     }  } 

i getting null pointer exception in soap :-

<s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">    <s:body>       <s:fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">          <faultcode>s:server</faultcode>          <faultstring>java.lang.nullpointerexception</faultstring>       </s:fault>    </s:body> </s:envelope> 

can try run code , tell me mistakes? need add few jax-ws jars in lib run code.

i have followed few online tutorials on how deploy jax-ws web service in tomcat. have created web service class , annotated @webservice, written web.xml , sun-jaxws.xml file, packaged files (plus jax-ws jar files) .war file, , deployed tomcat. appears working, can load wsdl file in browser pointed @ tomcat.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -