Search in sources :

Example 1 with WebMethod

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());
        }
    }
}
Also used : WebMethod(jakarta.jws.WebMethod) Action(jakarta.xml.ws.Action)

Example 2 with WebMethod

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);
}
Also used : MessageContext(jakarta.xml.ws.handler.MessageContext) WebMethod(jakarta.jws.WebMethod)

Example 3 with WebMethod

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;
}
Also used : MessageContext(jakarta.xml.ws.handler.MessageContext) WebMethod(jakarta.jws.WebMethod)

Example 4 with WebMethod

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);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) List(java.util.List) ArrayList(java.util.ArrayList) MessageContext(jakarta.xml.ws.handler.MessageContext) Map(java.util.Map) HashMap(java.util.HashMap) WebMethod(jakarta.jws.WebMethod)

Example 5 with WebMethod

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);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) MessageContext(jakarta.xml.ws.handler.MessageContext) WebMethod(jakarta.jws.WebMethod)

Aggregations

WebMethod (jakarta.jws.WebMethod)19 MessageContext (jakarta.xml.ws.handler.MessageContext)13 List (java.util.List)7 WebServiceException (jakarta.xml.ws.WebServiceException)6 Map (java.util.Map)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 SOAPBinding (jakarta.jws.soap.SOAPBinding)2 Result (calculator.Result)1 Page (fromjava.cr6940117.pak2.bean.Page)1 Oneway (jakarta.jws.Oneway)1 Action (jakarta.xml.ws.Action)1 BigInteger (java.math.BigInteger)1 VariableElement (javax.lang.model.element.VariableElement)1 TypeMirror (javax.lang.model.type.TypeMirror)1 QName (javax.xml.namespace.QName)1