服务器无法识别HTTP Header SOAPAction java错误的值

时间:2015-11-12 14:49:49

标签: java web-services soap

我需要从我的java代码中调用另一个Web服务。所以我写下面的代码。

    QName serviceQName = new QName(targetNamespace, webserviceName);
    QName portQName = new QName(targetNamespace, portName);

    Service service = Service.create(serviceQName);
    service.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, endpointUrl);
    Dispatch<SOAPMessage> dispatch = service.createDispatch(portQName, SOAPMessage.class, Service.Mode.MESSAGE);

    SOAPMessage sOAPMessage = messageFactory.createMessage();
    SOAPPart sOAPPart = sOAPMessage.getSOAPPart();
    SOAPEnvelope sOAPEnvelope = sOAPPart.getEnvelope();
    SOAPBody sOAPBody = sOAPEnvelope.getBody();
    Document bodyDocument = XmlUtil.createDocument(operationName, targetNamespace, "pre");
        bodyDocument = XmlUtil.wrapDocument(bodyDocument, parameterDocument);
    }
    sOAPBody.addDocument(bodyDocument);

    MimeHeaders headers = sOAPMessage.getMimeHeaders();
    headers.addHeader("SOAPAction", targetNamespace + operationName);

    // calling SOAP webservice operation
    SOAPMessage response = dispatch.invoke(sOAPMessage);

    Object resultObj = JAXBUtil.unmarshalFromNode(resultNode, resultObjectUnmarshallerClasses);
    return resultObj;

我添加了像这样的SOAPAction标头

MimeHeaders headers = sOAPMessage.getMimeHeaders();
headers.addHeader("SOAPAction", targetNamespace + operationName);

但是当我打电话给它时,它会抛出异常。怎么了。

异常:客户端从服务器收到SOAP Fault:System.Web.Services.Protocols.SoapException:Server无法识别HTTP Header SOAPAction的值:

0 个答案:

没有答案