获取javax.xml.soap.SOAPException:通过Java调用Web服务时,Oracle weblogic服务器上的Content-Type未指定错误

时间:2018-06-17 10:37:39

标签: java oracle web-services soap weblogic

我使用Jdeveloper工具编写了一个java代码来调用外部Web服务。当我从Jdeveloper运行我的代码时它工作正常。但我正在Oracle weblogic 10.3.6服务器上部署我的代码并尝试运行此代码然后它给我以下错误 -

javax.xml.soap.SOAPException:未指定Content-Type

这是我的代码 -

var canvas = new fabric.Canvas('c');
let gridSize = 15;
var text = new fabric.Text('Grid',{left:canvas.width/2,top:canvas.height/2})

$("#addAsGroup").click(() => {
    canvas.clear();
    let separateLines = [];
    for (let i = 0; i < canvas.getWidth() / gridSize; i++) {
        let horizontalLine = new fabric.Line(
            [i * gridSize, 0, i * gridSize, canvas.getWidth()], {
                stroke: '#000'
            });
        let verticalLine = new fabric.Line(
            [0, i * gridSize, canvas.getWidth(), i * gridSize], {
                stroke: '#000'
            });
        separateLines.push(horizontalLine);
        separateLines.push(verticalLine);
    }
    
    // add lines to group
    let group = new fabric.Group([...separateLines,text]);
    canvas.add(group);
});

$("#addAsSeparateObjects").click(() => {
    canvas.clear();
    let separateLines = [];
    for (let i = 0; i < canvas.getWidth() / gridSize; i++) {
        let horizontalLine = new fabric.Line(
            [i * gridSize, 0, i * gridSize, canvas.getWidth()], {
                stroke: '#000'
            });
        let verticalLine = new fabric.Line(
            [0, i * gridSize, canvas.getWidth(), i * gridSize], {
                stroke: '#000'
            });
        separateLines.push(horizontalLine);
        separateLines.push(verticalLine);
    }
    separateLines.forEach((line) => {
        canvas.add(line);
    })
    canvas.add(text)
});

我尝试了很多不同的东西,但是当我直接从Jdeveloper调用Web服务但是当我从Oracle Web逻辑服务器调用时它失败了。

你能帮帮我吗?

1 个答案:

答案 0 :(得分:0)

我已修复此问题。请在代码中进行以下更改。

MimeHeaders headers1 = new MimeHeaders();

             headers1.setHeader("Content-Type", "text/xml");
             headers1.setHeader("Encoding", "UTF-8");
//    SOAPMessage soapRequest =
  //      MessageFactory.newInstance().createMessage(new MimeHeaders(),
    //                                               new ByteArrayInputStream(soapRequestXml.getBytes(Charset.forName("UTF-8"))));

    SOAPMessage soapRequest = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL).createMessage(headers1 ,
             new ByteArrayInputStream(soapRequestXml.getBytes(Charset.forName("UTF-8"))));