use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class SOAPTestHandler method handleMessage.
public boolean handleMessage(SOAPMessageContext smc) {
try {
SOAPMessage message = smc.getMessage();
SOAPBody body = message.getSOAPBody();
SOAPElement paramElement = (SOAPElement) body.getFirstChild().getFirstChild();
int number = Integer.parseInt(paramElement.getValue());
if (number == THROW_RUNTIME_EXCEPTION) {
throw new RuntimeException("EXPECTED EXCEPTION");
} else if (number == THROW_PROTOCOL_EXCEPTION) {
throw new ProtocolException("EXPECTED EXCEPTION");
} else if (number == THROW_SOAPFAULT_EXCEPTION) {
// todo
}
paramElement.setValue(String.valueOf(++number));
} catch (SOAPException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return true;
}
use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class ClientHandler method handleMessage.
/*
* The method that does the testing. If a context property is
* missing or invalid, throw a RuntimeException and it will
* cause the test to fail.
*/
public boolean handleMessage(SOAPMessageContext context) {
SOAPMessage sm = context.getMessage();
try {
SOAPBody sb = sm.getSOAPBody();
Node n = sb.getFirstChild();
if (n != null) {
if (!n.getLocalName().equals("picType") || !n.getNamespaceURI().equals("http://www.ws-i.org/SampleApplications/SupplyChainManagement/2003-07/Catalog.xsd")) {
return true;
}
} else {
return true;
}
} catch (SOAPException e) {
throw new WebServiceException(e);
}
if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
System.out.println("Client handler processing echoImageWithInfo() request!");
Map<String, DataHandler> attachs = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
if (attachs.size() != 2)
throw new WebServiceException("Expected 2 attacment, received :" + attachs.size());
} else {
System.out.println("Client handler processing echoImageWithInfo() response!");
Map<String, DataHandler> attachs = (Map<String, DataHandler>) context.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
if (attachs.size() != 3)
throw new WebServiceException("Expected 3 attacment, received :" + attachs.size());
}
return true;
}
use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class ServerHandler method handleMessage.
public boolean handleMessage(SOAPMessageContext context) {
SOAPMessage sm = context.getMessage();
try {
System.out.println("Inside ServerHandler...");
SOAPBody sb = sm.getSOAPBody();
Node n = sb.getFirstChild();
if (n != null) {
if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
if (n.getLocalName().equals("echo3Response")) {
if (!n.getNamespaceURI().equals("http://example.com/echo3"))
throw new WebServiceException("Expected: \"http://example.com/echo3\", got: " + n.getNamespaceURI());
else
return true;
}
if (!n.getNamespaceURI().equals("http://example.com/")) {
throw new WebServiceException("Expected: \"http://example.com/\", got: " + n.getNamespaceURI());
}
} else {
if (n.getLocalName().equals("echo3")) {
if (!n.getNamespaceURI().equals("http://tempuri.org/wsdl"))
throw new WebServiceException("Expected: \"http://tempuri.org/wsdl\", got: " + n.getNamespaceURI());
else
return true;
}
if (!n.getNamespaceURI().equals("http://tempuri.org/")) {
throw new WebServiceException("Expected: \"http://tempuri.org/\", got: " + n.getNamespaceURI());
}
}
} else {
return true;
}
} catch (SOAPException e) {
throw new WebServiceException(e);
}
return true;
}
use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class ServerHandler method handleMessage.
/*
* The method that does the testing. If a context property is
* missing or invalid, throw a RuntimeException and it will
* cause the test to fail.
*/
public boolean handleMessage(SOAPMessageContext context) {
SOAPMessage sm = context.getMessage();
try {
SOAPBody sb = sm.getSOAPBody();
Node n = sb.getFirstChild();
if (n != null) {
if (!n.getLocalName().equals("picType") || !n.getNamespaceURI().equals("http://www.ws-i.org/SampleApplications/SupplyChainManagement/2003-07/Catalog.xsd")) {
return true;
}
} else {
return true;
}
} catch (SOAPException e) {
throw new WebServiceException(e);
}
if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
System.out.println("Server handler processing echoImageWithInfo() request!");
Map<String, DataHandler> attachs = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
if (attachs == null)
throw new WebServiceException("Expected 3 attacment, received null!");
if (attachs.size() != 3)
throw new WebServiceException("Expected 3 attacment, received :" + attachs.size());
} else {
System.out.println("Server handler processing echoImageWithInfo() response!");
Map<String, DataHandler> attachs = (Map<String, DataHandler>) context.get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
if (attachs == null)
throw new WebServiceException("Expected 2 attacment, received null!");
if (attachs.size() != 2)
throw new WebServiceException("Expected 2 attacment, received :" + attachs.size());
}
return true;
}
use of jakarta.xml.soap.SOAPBody in project metro-jax-ws by eclipse-ee4j.
the class AllResponsesTest method testNonAnonymousFaultTo1.
/**
* Normal response case,just tests if the endpoint accepts non-anon FaultTo
* @throws Exception
*/
public void testNonAnonymousFaultTo1() throws Exception {
SOAPMessage response = invoke(createDispatchWithoutAddressing(), TestMessages.NON_ANONYMOUS_FAULT_TO_COMPLETE_MESSAGE, S11_NS, nonAnonAddress, action, endpointAddress, "testNonAnonymousReplyTo");
SOAPBody sb = response.getSOAPBody();
Iterator itr = sb.getChildElements(new QName("http://server.responses.wsa.fromjava/", "addNumbersResponse"));
assertTrue(itr.hasNext());
}
Aggregations