我有一个包含类和JSP的Web应用程序,我使用mvn clean package -Dmaven.test.skip=true
我在应用程序中有这个类:
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.servlet.http.HttpSession;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
@WebService(serviceName="IberiaWS")
public class IberiaWS {
@Resource
private WebServiceContext wsContext;
public IberiaWS () {
}
private UserVO getSessionUserVO() {
MessageContext mc = wsContext.getMessageContext();
HttpSession session = ((javax.servlet.http.HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
return (UserVO)session.getAttribute("uservo");
}
private void setSessionUserVO(UserVO uservo) {
MessageContext mc = wsContext.getMessageContext();
HttpSession session = ((javax.servlet.http.HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();
session.setAttribute("uservo", uservo);
}
@WebMethod
public boolean login(String loginName, String loginPwd) throws Exception {
this.setSessionUserVO(new UserDAO().findUser("_"+loginName, "__"+loginPwd));
return isConnected();
}
@WebMethod
public boolean isConnected() {
return (this.getSessionUserVO()!=null);
}
@WebMethod
public IberiaPerson getPerson(String id) {
return new IberiaPerson();
}
@WebMethod
public IberiaPerson findPerson(String companyNr) {
UserVO uservo = this.getSessionUserVO();
IberiaPerson ret=null;
PersonVO p= new PersonDAO().findByCompanyNr(uservo.getAdminCenterId(), uservo.getUserId(), "Iberia", companyNr);
if (p!=null) {
ret = new IberiaPerson();
ret.setPersonId(p.getPersonId());
ret.setCompanyName(p.getVehicleOwnerName());
ret.setCategoryName(p.getCategoryName());
ret.setCompanyNr(p.getCompanyNr());
ret.setFirstName(p.getFirstName());
ret.setLastName(p.getLastName());
ret.setStatusId(p.getStatusId());
ret.setGroupName(p.getGroupList());
ret.setKeyCode(p.getKeyString());
ret.setComments(p.getLmComment());
}
return ret;
}
}
我创建了战争并将其部署在Tomcat中。我想访问WS的WSDL,但我不知道该怎么做。显然我没有创建应用程序,我只是得到了源代码,但我不知道如何访问WS。由于应用程序部署在iberiafleet上下文中,我尝试了http://localhost:8080/iberiafleet/IberiaWSPort?WSDL,但我收到了HTTP 404错误
这是项目的web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
有没有办法用maven构建,打包和部署WS?
我已将web.xml更改为此,但我无法访问
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>
IberiaWSPort
</servlet-name>
<servlet-class>
com.iberia.webservice.IberiaWS
</servlet-class>
<load-on-startup>
1
</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>
IberiaWSPort
</servlet-name>
<url-pattern>
/IberiaWSPort
</url-pattern>
</servlet-mapping>
</web-app>
答案 0 :(得分:1)
请遵循以下示例代码
请参阅link
<?xml version="1.0" encoding="UTF-8"?><endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
<endpoint name="AccountDetailsServiceEndPoint" service ="{http://gognamunish.com/accounts}AccountDetailsService" port="{http://gognamunish.com/accounts}AccountDetailsPort" implementation="com.mg.ws.impl.AccountDetailsServiceImpl" url-pattern="/details" wsdl="WEB-INF/wsdl/accounts.wsdl"/></endpoints>