use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class SOAP12Factory method getDefaultFaultEnvelope.
@Override
public final SOAPEnvelope getDefaultFaultEnvelope() {
SOAPEnvelope defaultEnvelope = getDefaultEnvelope();
SOAPFault fault = createSOAPFault(defaultEnvelope.getBody());
SOAPFaultCode faultCode = createSOAPFaultCode(fault);
createSOAPFaultValue(faultCode);
SOAPFaultReason reason = createSOAPFaultReason(fault);
createSOAPFaultText(reason);
createSOAPFaultDetail(fault);
return defaultEnvelope;
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class SOAPFactoryImpl method createDefaultSOAPMessage.
@Override
public final SOAPMessage createDefaultSOAPMessage() {
SOAPMessage message = createSOAPMessage();
SOAPEnvelope env = createSOAPEnvelope();
message.addChild(env);
createSOAPBody(env);
return message;
}
use of org.apache.axiom.soap.SOAPEnvelope in project webservices-axiom by apache.
the class TestDataHandlerSerializationWithoutMTOM method runTest.
@Override
protected void runTest() throws Throwable {
SOAPFactory factory = metaFactory.getSOAP11Factory();
JAXBContext context = JAXBContext.newInstance(DocumentBean.class);
// Construct the original message
DocumentBean orgObject = new DocumentBean();
orgObject.setId("123456");
orgObject.setContent(new DataHandler("some content", "text/plain; charset=utf-8"));
SOAPEnvelope orgEnvelope = factory.getDefaultEnvelope();
OMSourcedElement element = factory.createOMElement(new JAXBOMDataSource(context, orgObject));
orgEnvelope.getBody().addChild(element);
// Serialize the message
ByteArrayOutputStream out = new ByteArrayOutputStream();
orgEnvelope.serialize(out);
assertFalse(element.isExpanded());
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(new ByteArrayInputStream(out.toByteArray()), null).getSOAPEnvelope();
DocumentBean object = (DocumentBean) context.createUnmarshaller().unmarshal(envelope.getBody().getFirstElement().getXMLStreamReader(false));
assertEquals("some content", IOUtils.toString(object.getContent().getInputStream(), "utf-8"));
}
use of org.apache.axiom.soap.SOAPEnvelope in project wso2-axis2-transports by wso2.
the class TCPWorker method run.
public void run() {
MessageContext msgContext = null;
try {
msgContext = endpoint.createMessageContext();
msgContext.setIncomingTransportName(Constants.TRANSPORT_TCP);
TCPOutTransportInfo outInfo = new TCPOutTransportInfo();
outInfo.setSocket(socket);
outInfo.setClientResponseRequired(endpoint.isClientResponseRequired());
outInfo.setContentType(endpoint.getContentType());
String delimiter = endpoint.getRecordDelimiter();
int recordLength = endpoint.getRecordLength();
String inputType = endpoint.getInputType();
String delimiterType = endpoint.getRecordDelimiterType();
outInfo.setDelimiter(delimiter);
outInfo.setDelimiterType(delimiterType);
msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
// create the SOAP Envelope
InputStream input = socket.getInputStream();
boolean handled = false;
if (recordLength > -1) {
this.handleRecordLength(msgContext, input, recordLength);
handled = true;
}
if (!delimiter.isEmpty() && !handled) {
if (inputType != null) {
if (TCPConstants.STRING_INPUT_TYPE.equalsIgnoreCase(inputType)) {
if (TCPConstants.BYTE_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
int delimiterVal = Integer.parseInt(delimiter.split("0x")[1], 16);
this.handleCharacterRecordDelimiterStringStream(msgContext, input, delimiterVal);
} else if (TCPConstants.STRING_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
this.handleStringRecordDelimiterStringStream(msgContext, input, delimiter);
} else {
this.handleCharacterRecordDelimiterStringStream(msgContext, input, delimiter.charAt(0));
}
} else {
if (TCPConstants.BYTE_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
int delimiterVal = Integer.parseInt(delimiter.split("0x")[1], 16);
this.handleCharacterRecordDelimiterBinaryStream(msgContext, input, delimiterVal);
} else if (TCPConstants.STRING_DELIMITER_TYPE.equalsIgnoreCase(delimiterType)) {
this.handleStringRecordDelimiterBinaryStream(msgContext, input, delimiter);
} else {
this.handleCharacterRecordDelimiterBinaryStream(msgContext, input, delimiter.charAt(0));
}
}
}
handled = true;
}
if (!handled) {
SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, input, endpoint.getContentType());
msgContext.setEnvelope(envelope);
AxisEngine.receive(msgContext);
}
} catch (Exception e) {
sendFault(msgContext, e);
} finally {
if (!endpoint.isClientResponseRequired()) {
try {
socket.close();
} catch (IOException e) {
log.error("Error while closing a TCP socket", e);
}
}
}
}
use of org.apache.axiom.soap.SOAPEnvelope in project wso2-axis2-transports by wso2.
the class TCPWorker method handleEnvelope.
private void handleEnvelope(MessageContext msgContext, byte[] value) throws AxisFault {
ByteArrayInputStream bais = null;
try {
bais = new ByteArrayInputStream(value);
SOAPEnvelope envelope = TransportUtils.createSOAPMessage(msgContext, bais, endpoint.getContentType());
msgContext.setEnvelope(envelope);
AxisEngine.receive(msgContext);
} catch (IOException e) {
sendFault(msgContext, e);
} catch (XMLStreamException e) {
sendFault(msgContext, e);
} finally {
if (bais != null) {
try {
bais.close();
} catch (IOException e) {
sendFault(msgContext, e);
}
}
}
}
Aggregations