2

I was wondering if it is possible to send a byte[] over the Soap Request. Is it? If so, how can i do it using javax.xml.soap.*?

I only know how to do it sending strings.

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("[email protected]");

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

    soapMessage.saveChanges();

    soapMessage.writeTo(System.out);

    return soapMessage;
}

The ws signature is:

@WebMethod(operationName = "ronkNow", action = "urn:rs")
Response ronkNow(@WebParam(name = "file")byte[] data);
1
  • Did you ever solve this issue? I have the exact same problem... Commented Mar 8, 2018 at 10:37

1 Answer 1

0

Can't you just convert your byte array to String then ?

http://www.javacodegeeks.com/2014/09/2-examples-to-convert-byte-array-to-string-in-java.html

Converting byte array to String (Java)

Sign up to request clarification or add additional context in comments.

1 Comment

No, i'm trying to simulate something on my company and i need to use byte[]. Is it possible?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.