将肥皂消息发送到weblogic jms队列

时间:2019-02-27 09:29:21

标签: java soap jms weblogic

我正在使用Weblogic jms Queue发送肥皂请求(这是我在Java代码中作为肥皂消息手动形成的)。我们有一个被调用的webservice,一旦被调用,就会从这些参数调用inject(String type,businessoid,String PayLoad),我正在形成肥皂消息,并使用TransformerFactory类将其转换为String。

我已经在本地系统中使用伪数据进行了测试,可以发送它,但是当我将其部署到weblogic服务器时,实际的肥皂消息不会发送到队列。当我从SOAP ui测试从服务器部署n时,当我排除SOAP消息并形成一些String硬编码的msg时,它能够发送jms队列。

这是我形成肥皂消息的代码     公共SOAPMessage createSOAPMessage(字符串类型,字符串businessObjectId,有效负载有效载荷)引发异常{

    LOG.debug("inside createSOAPMessage method...");
    SOAPBody soapBody = null;
    MessageFactory messageFactory;
    try {
        messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();

        String ksNamespace = "soapenv";
        String ksNamespaceURI = "http://schemas.xmlsoap.org/soap/envelope/";

        // SOAP Envelope
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.setPrefix("soapenv");
        envelope.removeNamespaceDeclaration("SOAP-ENV");
        soapBody = envelope.getBody();
        soapMessage.getSOAPBody().setPrefix("soapenv");
        soapMessage.getSOAPHeader().setPrefix("soapenv");
        SOAPHeader header = envelope.getHeader();
        envelope.addNamespaceDeclaration(ksNamespace, ksNamespaceURI);
        envelope.addNamespaceDeclaration("v1",
                "http://www.oracle.com/retail/rib/integration/services/InjectorService/v1");

        // Constructed SOAP Message:
        // SOAP Body
        soapBody = envelope.getBody();
        SOAPElement soapBodyElem1 = soapBody.addChildElement("inject");
        soapBodyElem1.setPrefix("v1");
        SOAPElement soapBodyFamily = soapBodyElem1.addChildElement("family");
        SOAPElement soapBodyMessageType = soapBodyElem1.addChildElement("messageType");
        SOAPElement soapBodyBusinessObjectId = soapBodyElem1.addChildElement("businessObjectId");
        SOAPElement soapBodyRetailPayload = soapBodyElem1.addChildElement("retailPayload");

        soapBodyFamily.addTextNode(messagefamily);
        soapBodyMessageType.addTextNode(messagetype);
        soapBodyBusinessObjectId.addTextNode(businessId);
        messagepayload = PayloadFactory.marshalPayload(payload);

        if (messagepayload == null) {

            throw new RetailBusinessException("(" + "marshalPayload is null.." + ")");
        } else {

            soapBodyRetailPayload.addTextNode(messagepayload);
        }

            /*
         * soapBodyFamily.addTextNode("PO");
         * soapBodyMessageType.addTextNode("PO Delete");
         * soapBodyBusinessObjectId.addTextNode("9824563");
         */
        soapMessage.saveChanges();
        return soapMessage;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        LOG.error(e);
        throw new Exception(e.getMessage());

    }

}

0 个答案:

没有答案