I have the following code:
private SOAPEnvelope toEnvelope(SOAPFactory factory, CreateCaseRequestBodyDocument param, boolean optimizeContent, QName elementQName) throws AxisFault {
SOAPEnvelope envelope = factory.getDefaultEnvelope();
if (param != null)
envelope.getBody().addChild((OMNode)toOM(param, optimizeContent));
return envelope;
}
public CaseResponseBodyDocument createCase(CreateCaseRequestBodyDocument body1) throws RemoteException {
MessageContext _messageContext = new MessageContext();
try {
OperationClient _operationClient = this._serviceClient.createClient(this._operations[1].getName());
_operationClient.getOptions().setAction("http://sample/CreateCaseRequest");
_operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true);
addPropertyToOperationClient(_operationClient, "whttp:queryParameterSeparator", "&");
SOAPEnvelope env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), body1, optimizeContent(new QName("http://sampleurl/", "createCase")), new QName("sampleurl/", "CreateCaseRequestBody"));
this._serviceClient.addHeadersToEnvelope(env);
_messageContext.setEnvelope(env);
_operationClient.addMessageContext(_messageContext);
_operationClient.execute(true);
MessageContext _returnMessageContext = _operationClient.getMessageContext("In");
SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope();
Object object = fromOM(_returnEnv.getBody().getFirstElement(), CaseResponseBodyDocument.class);
return (CaseResponseBodyDocument) object;
} catch (AxisFault f) {
// Handle the exception
}
}
body1 has the following data:
<CreateCaseRequestBody xmlns="http://sampleurl.com/">
<caseId xmlns="">402910</caseId>
<caseXML xmlns="">
</CreateCaseRequestBody>
The _messageContext.setEnvelope(env) returns the following format:
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ones:CreateCaseRequestBody xmlns:ones="http://sampleurl.com/">
<caseXML><?xml version="1.0" encoding="UTF-8" standalone="yes"?>
</caseXML>
</ones:CreateCaseRequestBody>
</soapenv:Body>
</soapenv:Envelope>
However, I want SOAP to return SOAP XML in the following format:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ones="http://sampleurl.com/">
<soapenv:Header/>
<soapenv:Body>
<ones:CreateCaseRequestBody>
<caseXML>
</caseXML>
</ones:CreateCaseRequestBody>
</soapenv:Body>
</soapenv:Envelope>
You can see this format does not include:
<?xml version='1.0' encoding='utf-8'?>
and has the <soapenv:Header/> tag.
Please assist me with this, thank you so much!
New contributor
lala160523 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.