In target WebService in response is only xs:base64binary
and JAXB does not generate a response type.
In my invoke:
public Object signMessage(SigningRequestType request) {
JAXBElement<SigningRequestType> jAXBElement = new ObjectFactory().createSigningRequestType(request);
return getWebServiceTemplate().marshalSendAndReceive(jAXBElement,
new SoapActionCallback(SIGN_METHOD_ACTION));
}
returns an Object
and I can't simply cast to byte[]
or serialize it.
How can I extract a byteArray result from the response?
UDP: Add a little more information.
ObjectFactory()
method:
@XmlElementDecl(namespace = "http://www.roskazna.ru/eb/sign/types/sgv", name = "SigningResponseType")
public JAXBElement<byte[]> createSigningResponseType(byte[] value) {
return new JAXBElement<byte[]>(_SigningResponseType_QNAME, byte[].class, null, ((byte[]) value));
}
XSD:
<xs:element name="SigningResponseType" type="cst:notEmptyB64Binary"/>
Helped my colleague Senior.
In this case marshalSendAndReceive()
returns JAXBElement
in fact. So:
public byte[] signMessage(SigningRequestType request) throws IOException {
JAXBElement<SigningRequestType> jAXBElement
= new ObjectFactory().createSigningRequestType(request);
final Object o = getWebServiceTemplate().marshalSendAndReceive(jAXBElement,
new SoapActionCallback("http://www.roskazna.ru/eb/sign/types/sgv/Sign"));
return (byte[]) ((JAXBElement) o).getValue();
}