javax.xml.ws.WebServiceException

时间:2019-01-08 15:42:51

标签: java spring maven soap-client webservice-client

我正在使用Spring MVC和Eclipse开发一个Web服务客户端(Soap),并收到以下错误消息:

  

嵌套的异常是javax.xml.ws.WebServiceException:方法   checkToken作为WebMethod公开,但是没有相应的wsdl   名称操作

我做了什么:

  • 使用psvm调用相同的方法创建了一个测试类
  • 尝试根据某些StackOverflow帖子添加cxf-rt-frontend-jaxws

我得到一个 500 页面:

  

类型异常报告

     

消息请求处理失败;嵌套异常为   javax.xml.ws.WebServiceException:方法checkToken公开为   WebMethod,但是没有名称对应的wsdl操作   {http://troparo.org/services/ConnectService/}中的checkToken   wsdl:portType {http://troparo.org/services/ConnectService/} IConnectService

     

说明服务器遇到意外情况,   阻止它满足请求。

例外:

  

org.springframework.web.util.NestedServletException:请求   处理失败;嵌套异常为   javax.xml.ws.WebServiceException:方法checkToken公开为   WebMethod,但是没有名称对应的wsdl操作   {http://troparo.org/services/ConnectService/}中的checkToken   wsdl:portType {http://troparo.org/services/ConnectService/} IConnectService     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1013)     org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)     javax.servlet.http.HttpServlet.service(HttpServlet.java:634)     org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)     javax.servlet.http.HttpServlet.service(HttpServlet.java:741)     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

     

根本原因javax.xml.ws.WebServiceException:方法checkToken是   公开为WebMethod,但没有相应的wsdl操作   名称为{http://troparo.org/services/ConnectService/} checkToken in   的   wsdl:portType {http://troparo.org/services/ConnectService/} IConnectService

错误(checkToken)中的方法确实存在,并且在从隔离类中调用时可以正常工作

<dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>${jstl.version}</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxws -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.2.7</version>
    </dependency>

    <!-- compile only, deployed container will provide this -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${servletapi.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.3.1</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-core -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-core</artifactId>
        <version>3.2.7</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-transports-http -->
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>3.2.7</version>
    </dependency>

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>3.2.7</version>
    </dependency>

我的控制器:

@RequestMapping(value = "/login", method = RequestMethod.GET)
public ModelAndView add(@RequestParam("login") String login, @RequestParam("password") String password) {
        ConnectService cs = new ConnectService();
        GetTokenRequestType t = new GetTokenRequestType();
        t.setLogin("lokii");
        t.setPassword("111");
        try {
            GetTokenResponseType responseType = cs.getConnectServicePort().getToken(t);
            System.out.println("response: " + responseType.getReturn());
        } catch (BusinessException e) {
            e.printStackTrace();
        }

        ModelAndView mv = new ModelAndView();
        String name = "Hello " + login;
        mv.addObject("token", token);
        mv.setViewName("result");
        return mv;
}

名为的方法需要登录并输入密码才能返回令牌对象

谢谢!

0 个答案:

没有答案