【问题标题】:Error with Web Service SOAP (Java)Web 服务 SOAP (Java) 错误
【发布时间】:2018-08-20 19:30:42
【问题描述】:

我有这个网络服务:

@WebService
public interface IRobotWhatsappService {

@WebMethod
@WebResult(name = "resultRobotWhatsapp")
public ResultRobotWhatsapp login (@WebParam(name = "correoPersonaQueEscanea") String correoPersonaQueEscanea);

@WebMethod
@WebResult(name = "resultRobotWhatsapp")
public ResultRobotWhatsapp leer  (@WebParam(name = "nombreContactoParaLeer") String nombreContactoParaLeer,
                                  @WebParam(name = "identificadorSesion") String identificadorSesion);

@WebMethod
@WebResult(name = "resultRobotWhatsapp")
public ResultRobotWhatsapp enviar(@WebParam(name = 
"nombreContactoDestinatario") String nombreContactoDestinatario,
                                  @WebParam(name = "mensaje")String mensaje,
                                  @WebParam(name = "identificadorSesion") 
                                  String identificadorSesion);
}

而且我有最基本的实现:

@WebService(endpointInterface = "com.test.application.robot.ws.IRobotWhatsappService")
public class RobotWhatsappService implements IRobotWhatsappService{

@Override
public ResultRobotWhatsapp login(String correoPersonaQueEscanea) {
    ResultRobotWhatsapp resultRobotWhatsapp =new ResultRobotWhatsapp(); 
    resultRobotWhatsapp.setMessage("Login");
    return resultRobotWhatsapp;
}

@Override
public ResultRobotWhatsapp leer(String nombreContactoParaLeer, String identificadorSesion) {
    ResultRobotWhatsapp resultRobotWhatsapp =new ResultRobotWhatsapp();
    resultRobotWhatsapp.setMessage("Leer");
    return resultRobotWhatsapp;
}

@Override
public ResultRobotWhatsapp enviar(String nombreContactoDestinatario, String mensaje, String identificadorSesion) {
    ResultRobotWhatsapp resultRobotWhatsapp =new ResultRobotWhatsapp();
    resultRobotWhatsapp.setMessage("Enviar");
    return resultRobotWhatsapp;
}

}

在我的 web.xml 中我有这个配置:

<servlet>
    <display-name>CXF Servlet</display-name>
    <servlet-name>CXFServlet</servlet-name>     
    <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>CXFServlet</servlet-name>
    <url-pattern>/soap/*</url-pattern>
</servlet-mapping> 

我的 WS 正确显示了方法,但是当我发出请求时,我得到了 405 状态错误的 jsp。 在我的 securityContext.xml 我有一个例外:

<sec:intercept-url pattern="/RobotWhatsapp**" access="permitAll" />
<sec:intercept-url pattern="/soap/**" access="permitAll" />

在我的应用程序上下文 xml 中,我有 bean 和端点:

<bean id="robotWhatsappImplBean" class="com.konecta.application.robot.ws.RobotWhatsappService" />
<jaxws:endpoint id="robotWhatsappImpl" implementor="#robotWhatsappImplBean" address="/RobotWhatsapp" /> 

你对这个问题有什么想法吗?

这是一个soapui的例子:

从这里开始http://cxf.apache.org/docs/writing-a-service-with-spring.html

【问题讨论】:

    标签: java web-services soap http-status-code-405 servlet-listeners


    【解决方案1】:

    我正在使用带有 CSRF 保护的 springSecurityFilterChain。这意味着我必须在发出请求时发送令牌。 一切都很好,只是我需要在我的安全上下文中添加这个:

    <sec:csrf disabled="true" />
    

    如果您在 .java 文件中有该配置,您可以这样做:

    .and().csrf().disable();
    

    在您的过滤器中

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多