简体   繁体   English

使用Apache cxf的Dispatch API时,SOAP Action为空

[英]SOAP Action is empty while using Dispatch api of Apache cxf

I am using Apache cxf for the the soap client. 我正在使用Soap客户端的Apache cxf。 While firing the request, even though after setting the SOAPAction in the MIME header, it gets changed to ""(empty string). 在触发请求时,即使在MIME标头中设置了SOAPAction之后,它也会更改为“”(空字符串)。 Kindly provide a solution to solve this case. 请提供解决此问题的解决方案。 Following is the code 以下是代码

public class TempEg {

public static void main(String[] args) throws SOAPException, IOException {

    String withOutAuthBody="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns=\"http://www.webserviceX.NET/\"><soapenv:Body><ns:ConvertTemp><ns:Temperature>35</ns:Temperature><ns:FromUnit>degreeCelsius</ns:FromUnit><ns:ToUnit>degreeFahrenheit</ns:ToUnit></ns:ConvertTemp></soapenv:Body></soapenv:Envelope>";


    String wsdlURLWithOutAuth="http://www.webservicex.net/ConvertTemperature.asmx?wsdl";



    MessageFactory factory = MessageFactory.newInstance();
    System.out.println(wsdlURLWithOutAuth + "\n\n");

    QName serviceName = new QName("http://www.webserviceX.NET/","ConvertTemperature");
    QName portName = new QName("http://www.webserviceX.NET/","ConvertTemperatureSoap");

    Service service1 = Service.create(new URL(wsdlURLWithOutAuth),serviceName);

    InputStream is1 = new ByteArrayInputStream(withOutAuthBody.getBytes());
    SOAPMessage soapReq1 = factory.createMessage(null, is1);




    Dispatch<SOAPMessage> dispSOAPMsg1 = service1.createDispatch(portName,
         SOAPMessage.class, Mode.MESSAGE);



    MimeHeaders headers = soapReq1.getMimeHeaders();
    headers.addHeader("SOAPAction", "http://www.webserviceX.NET/ConvertTemp");



    System.out.println("Invoking server through Dispatch interface using SOAPMessage");


    SOAPMessage soapResp = dispSOAPMsg1.invoke(soapReq1);
    System.out.println("Response from server: " + soapResp.getSOAPBody().getTextContent());


}

} }

This is the error I am getting after running the above code. 这是运行以上代码后出现的错误。

    Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .
   at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
    at org.apache.cxf.jaxws.DispatchImpl.mapException(DispatchImpl.java:287)
    at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:408)
    at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:243)
    at demo.hwDispatch.client.TempEg.main(TempEg.java:76)
Caused by: org.apache.cxf.binding.soap.SoapFault: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: .
   at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51)
    at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:798)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1636)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1525)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1330)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:638)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:514)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:423)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:326)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:279)
    at org.apache.cxf.endpoint.ClientImpl.invokeWrapped(ClientImpl.java:314)
    at org.apache.cxf.jaxws.DispatchImpl.invoke(DispatchImpl.java:401)
    ... 2 more

This is the SOAPAction I could see whiling capturing the request through fiddler. 我可以看到这是通过提琴手捕获请求的SOAPAction。

SOAPAction: ""

Looks like a bug, please submit a bug report + test-case here: https://issues.apache.org/jira/browse/CXF 看起来像个错误,请在此处提交错误报告+测试用例: https : //issues.apache.org/jira/browse/CXF

Colm. 科尔姆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM