use of jakarta.xml.ws.handler.MessageContext in project metro-jax-ws by eclipse-ee4j.
the class EchoImpl method echoString.
public String echoString(String str) throws Exception1, Fault1, WSDLBarException {
MessageContext ctxt = wsc.getMessageContext();
Map<String, List<String>> hdrs = (Map<String, List<String>>) ctxt.get(MessageContext.HTTP_REQUEST_HEADERS);
if (str == null) {
return null;
} else if (str.equals("Exception1")) {
throw new Exception1("my exception1");
} else if (str.equals("Fault1")) {
FooException fooException = new FooException();
fooException.setVarString("foo");
fooException.setVarInt(33);
fooException.setVarFloat(44F);
throw new Fault1("fault1", fooException);
} else if (str.equals("WSDLBarException")) {
throw new WSDLBarException("my barException", new Bar(33));
} else {
List<String> ctList = hdrs.get("Content-Type");
if (ctList == null || ctList.size() != 1) {
throw new WebServiceException("Invalid Content-Type header=" + ctList);
}
String ct = ctList.get(0).toLowerCase();
if (!(ct.contains(str.toLowerCase()))) {
throw new WebServiceException("Invalid Encoding for request. Expected=" + str + " Got Content-Type header=" + ctList);
}
}
return str;
}
use of jakarta.xml.ws.handler.MessageContext in project metro-jax-ws by eclipse-ee4j.
the class EchoImpl method echoString.
public String echoString(String str) throws Exception1, Fault1, WSDLBarException {
MessageContext ctxt = wsc.getMessageContext();
Map<String, List<String>> hdrs = (Map<String, List<String>>) ctxt.get(MessageContext.HTTP_REQUEST_HEADERS);
if (str == null) {
return null;
} else if (str.equals("Exception1")) {
throw new Exception1("my exception1");
} else if (str.equals("Fault1")) {
FooException fooException = new FooException();
fooException.setVarString("foo");
fooException.setVarInt(33);
fooException.setVarFloat(44F);
throw new Fault1("fault1", fooException);
} else if (str.equals("WSDLBarException")) {
throw new WSDLBarException("my barException", new Bar(33));
} else {
List<String> ctList = hdrs.get("Content-Type");
if (ctList == null || ctList.size() != 1) {
throw new WebServiceException("Invalid Content-Type header=" + ctList);
}
String ct = ctList.get(0).toLowerCase();
if (!(ct.contains(str.toLowerCase()))) {
throw new WebServiceException("Invalid Encoding for request. Expected=" + str + " Got Content-Type header=" + ctList);
}
}
return str;
}
use of jakarta.xml.ws.handler.MessageContext in project metro-jax-ws by eclipse-ee4j.
the class HelloServiceImpl method introduce.
@WebMethod
public void introduce() {
Map<String, List<String>> hdrs = new HashMap<String, List<String>>();
hdrs.put("Set-Cookie", Collections.singletonList("a=b"));
MessageContext mc = wsc.getMessageContext();
mc.put(MessageContext.HTTP_RESPONSE_HEADERS, hdrs);
}
use of jakarta.xml.ws.handler.MessageContext in project metro-jax-ws by eclipse-ee4j.
the class HelloServiceImpl method rememberMe.
@WebMethod
public boolean rememberMe() {
MessageContext mc = wsc.getMessageContext();
Map<String, List<String>> hdrs = (Map<String, List<String>>) mc.get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> cookieList = hdrs.get("Cookie");
if (cookieList == null || cookieList.get(0) == null || !cookieList.get(0).equals("a=b")) {
return false;
}
return true;
}
use of jakarta.xml.ws.handler.MessageContext in project metro-jax-ws by eclipse-ee4j.
the class HelloServiceImpl method rememberMe.
@WebMethod
public void rememberMe() {
MessageContext mc = wsc.getMessageContext();
Map<String, List<String>> hdrs = (Map<String, List<String>>) mc.get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> cookieList = hdrs.get("Cookie");
if (cookieList == null || cookieList.size() != 2) {
throw new WebServiceException("Expecting two cookies, Got=" + cookieList);
}
String cookie1 = cookieList.get(0);
String cookie2 = cookieList.get(1);
if (!((cookie1.equals("a=b") && cookie2.equals("c=d")) || (cookie1.equals("c=d") && cookie2.equals("a=b")))) {
throw new WebServiceException("Cookies are not matiching, Got=" + cookieList);
}
}
Aggregations