我有一个带有类和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;
}
}
我创建战争并将其部署在雄猫中。我想访问WS的WSDL,但我不知道该怎么做。显然我没有创建应用程序,我只是得到了源代码,但我不知道如何访问 WS。由于应用程序部署在上下文 iberiafleet 中,我尝试 http://localhost:8080/iberiafleet/IberiaWSPort?WSDL 但收到 HTTP 404 错误
这是该项目的网络.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
?我已经更改了网络.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>
请按照以下示例代码进行操作
请参考链接
<?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>