Apache CXF - The given SOAPAction does not match an operation

前端 未结 3 1612
面向向阳花
面向向阳花 2021-01-18 05:39

I started working again on a project I started a few years ago (code available here: http://code.google.com/p/mipnp/). It\'s a UPnP mediaserver that can stream media to an x

3条回答
  •  礼貌的吻别
    2021-01-18 06:00

    I have the same problem long time agos, I tried to add

    @EndpointProperty(key="soap.no.validate.parts", value="true")

    but that doesn't help, in my case I don't own the web service that i was consuming and the response of that web service doesn't follow the rules of the WSDL, so i ended changing the response with and interceptor like this one:

    /*Interceptor class */

    public class MyInterceptor extends AbstractPhaseInterceptor {
    
    private static final Logger logger = Logger.getLogger(MyInterceptor.class);
    
    public MyInterceptor() {
        super(Phase.RECEIVE);
    }
    
    @Override
    public void handleMessage(Message message) throws Fault {
        logger.info("TCP-InterceptandoMensaje");
        message.put(Message.ENCODING, "UTF-8");
        InputStream is = message.getContent(InputStream.class);
    
        if(is!=null){
            CachedOutputStream bos = new CachedOutputStream();
            try{
                IOUtils.copy(is, bos);
                String soapMessage = new String(bos.getBytes());
                logger.info("-------------------------------------------");
                logger.info("TCP-SoapMsgRecibido[" + soapMessage +"]");
                logger.info("-------------------------------------------");
                bos.flush();
                message.setContent(InputStream.class, is);
    
                is.close();
                InputStream inputStream = new ByteArrayInputStream(removeBody(soapMessage).getBytes());
                message.setContent(InputStream.class, inputStream);
                bos.close();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }
    
    private String removeBody(String msg) {
        StringBuffer soapMsg = new StringBuffer();
        if (msg.contains("Reason")) {
            if (msg.contains("TarjetaCreditoConsultaDetalle_Req")) {
                soapMsg.append(msg.substring(0, msg.indexOf("")));
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("000000000000000000000000");
                soapMsg.append("000");
                soapMsg.append("000");
                soapMsg.append("0");
                soapMsg.append("000");
                soapMsg.append("0");
                soapMsg.append("00000000");
                soapMsg.append("000000");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("000");
                soapMsg.append("000");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("0");
                soapMsg.append("0000000000000000");
                soapMsg.append(" ");
                soapMsg.append("USD");
                soapMsg.append("00000000");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append(" ");
                soapMsg.append("00000000");
                soapMsg.append("00000000");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("00000000");
                soapMsg.append("00000000");
                soapMsg.append("00000000");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("");
                soapMsg.append("1");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("0.00");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("");
                soapMsg.append("");            
            } else
                soapMsg.append(msg);
        } else
            soapMsg.append(msg);
        logger.info("EditedSoapMsg["+soapMsg+"]");
        return soapMsg.toString();
    }`
    

    My spring-config looks like:

    
    
    
        
            
                
            
        
    
    

    I hope this help someone with the same problem.

提交回复
热议问题