Java - 如何在Soap Request上发送字节数组?

时间:2015-06-08 23:29:25

标签: java soap

我想知道是否可以通过Soap Request发送一个byte []。是吗?如果是这样,我怎样才能使用javax.xml.soap。*?

我只知道如何发送字符串。

ans =

     3     8

ws签名是:

private static SOAPMessage createSOAPRequest() throws Exception {
    MessageFactory messageFactory = MessageFactory.newInstance();
    SOAPMessage soapMessage = messageFactory.createMessage();
    SOAPPart soapPart = soapMessage.getSOAPPart();


    SOAPEnvelope envelope = soapPart.getEnvelope();
    envelope.addNamespaceDeclaration("ws", "http://www.qwert.com.ar/");

    SOAPBody soapBody = envelope.getBody();
    SOAPElement soapBodyElem = soapBody.addChildElement("ronkMotor", "ws");
    SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("file");

    //How to add byte[] here?
    //soapBodyElem1.addTextNode("mutantninja@gmail.com");

    MimeHeaders headers = soapMessage.getMimeHeaders();
    headers.addHeader("SOAPAction", "ronkNow");

    soapMessage.saveChanges();

    soapMessage.writeTo(System.out);

    return soapMessage;
}

1 个答案:

答案 0 :(得分:0)