use of jakarta.xml.soap.SOAPElement 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.SOAPElement in project metro-jax-ws by eclipse-ee4j.
the class ProviderImpl method invoke.
/*
*/
public Source invoke(Source msg) {
if (!isInjectionDone()) {
throw new WebServiceException("Injection is not done");
}
// Test if we got the correct SOAPMessage that has handler changes
try {
MessageFactory fact = MessageFactory.newInstance();
SOAPMessage soap = fact.createMessage();
soap.getSOAPPart().setContent(msg);
SOAPBody body = soap.getSOAPBody();
Iterator i = body.getChildElements();
SOAPElement elem = (SOAPElement) i.next();
QName name = elem.getElementQName();
QName exp = new QName("urn:test:types", "MyVoidTest");
if (!exp.equals(name)) {
throw new WebServiceException("Handler changes aren't reflected");
}
} catch (SOAPException e) {
throw new WebServiceException("Got Incorrect Source");
}
printContext();
String content = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Body> <VoidTestResponse xmlns=\"urn:test:types\"></VoidTestResponse></soapenv:Body></soapenv:Envelope>";
Source source = new StreamSource(new ByteArrayInputStream(content.getBytes()));
return source;
}
use of jakarta.xml.soap.SOAPElement 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();
int number = Integer.parseInt(paramElement.getValue());
paramElement.setValue(String.valueOf(++number));
} catch (SOAPException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return true;
}
use of jakarta.xml.soap.SOAPElement in project metro-jax-ws by eclipse-ee4j.
the class TestHandler method handleMessage.
public boolean handleMessage(SOAPMessageContext context) {
try {
SOAPMessageContext smc = (SOAPMessageContext) context;
SOAPMessage message = smc.getMessage();
SOAPBody body = message.getSOAPBody();
SOAPElement paramElement = (SOAPElement) body.getFirstChild().getFirstChild();
int number = Integer.parseInt(paramElement.getValue());
paramElement.setValue(String.valueOf(++number));
} catch (SOAPException e) {
e.printStackTrace();
}
return true;
}
Aggregations