use of jakarta.jws.WebMethod in project metro-jax-ws by eclipse-ee4j.
the class JavaMethodImpl method setWsaActions.
private void setWsaActions(MetadataReader metadataReader) {
Action action = (metadataReader != null) ? metadataReader.getAnnotation(Action.class, seiMethod) : seiMethod.getAnnotation(Action.class);
if (action != null) {
inputAction = action.input();
outputAction = action.output();
}
// @Action(input) =="", get it from @WebMethod(action)
WebMethod webMethod = (metadataReader != null) ? metadataReader.getAnnotation(WebMethod.class, seiMethod) : seiMethod.getAnnotation(WebMethod.class);
soapAction = "";
if (webMethod != null)
soapAction = webMethod.action();
if (!soapAction.equals("")) {
// non-empty soapAction
if (inputAction.equals(""))
// set input action to non-empty soapAction
inputAction = soapAction;
else if (!inputAction.equals(soapAction)) {
// both are explicitly set via annotations, make sure @Action == @WebMethod.action
// http://java.net/jira/browse/JAX_WS-1108
// throw new WebServiceException("@Action and @WebMethod(action=\"\" does not match on operation "+ method.getName());
}
}
}
use of jakarta.jws.WebMethod 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.jws.WebMethod 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.jws.WebMethod 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);
}
}
use of jakarta.jws.WebMethod in project metro-jax-ws by eclipse-ee4j.
the class HelloServiceImpl method testHttpProperties.
@WebMethod
public void testHttpProperties() {
MessageContext ctxt = wsc.getMessageContext();
if (ctxt.get(MessageContext.HTTP_REQUEST_HEADERS) == null || ctxt.get(MessageContext.HTTP_REQUEST_METHOD) == null || !ctxt.get(MessageContext.HTTP_REQUEST_METHOD).equals("POST")) {
throw new WebServiceException("MessageContext is not populated.");
}
Map<String, List<String>> hdrs = (Map<String, List<String>>) ctxt.get(MessageContext.HTTP_REQUEST_HEADERS);
List<String> customHdrList = hdrs.get("custom-header");
if (customHdrList == null || customHdrList.size() != 1) {
throw new WebServiceException("MessageContext is not populated.");
}
String got = customHdrList.get(0);
if (!got.equals("custom-value")) {
throw new WebServiceException("Expected=" + "custom-value" + " got=" + got);
}
}
Aggregations