Search in sources :

Example 1 with WebMethod

use of javax.jws.WebMethod in project camel by apache.

the class SoapJaxbDataFormat method marshal.

/**
     * Marshal inputObjects to SOAP xml. If the exchange or message has an
     * EXCEPTION_CAUGTH property or header then instead of the object the
     * exception is marshaled.
     * 
     * To determine the name of the top level xml elements the elementNameStrategy
     * is used.
     * @throws IOException,SAXException 
     */
public void marshal(Exchange exchange, Object inputObject, OutputStream stream) throws IOException, SAXException {
    checkElementNameStrategy(exchange);
    String soapAction = getSoapActionFromExchange(exchange);
    if (soapAction == null && inputObject instanceof BeanInvocation) {
        BeanInvocation beanInvocation = (BeanInvocation) inputObject;
        WebMethod webMethod = beanInvocation.getMethod().getAnnotation(WebMethod.class);
        if (webMethod != null && webMethod.action() != null) {
            soapAction = webMethod.action();
        }
    }
    Object envelope = adapter.doMarshal(exchange, inputObject, stream, soapAction);
    // and continue in super
    super.marshal(exchange, envelope, stream);
}
Also used : WebMethod(javax.jws.WebMethod) BeanInvocation(org.apache.camel.component.bean.BeanInvocation)

Example 2 with WebMethod

use of javax.jws.WebMethod in project camel by apache.

the class ServiceInterfaceStrategy method analyzeMethod.

/**
     * Determines how the parameter object of the service method will be named
     * in xml. It will use either the RequestWrapper annotation of the method if
     * present or the WebParam method of the parameter.
     *
     * @param method
     */
private MethodInfo analyzeMethod(Method method) {
    List<TypeInfo> inInfos = getInInfo(method);
    TypeInfo outInfo = getOutInfo(method);
    WebMethod webMethod = method.getAnnotation(WebMethod.class);
    String soapAction = (webMethod != null) ? webMethod.action() : null;
    return new MethodInfo(method.getName(), soapAction, inInfos.toArray(new TypeInfo[inInfos.size()]), outInfo);
}
Also used : WebMethod(javax.jws.WebMethod)

Example 3 with WebMethod

use of javax.jws.WebMethod in project bamboobsc by billchen198318.

the class ManualJobServiceImpl method execute.

@WebMethod
@POST
@Path("/executeJob/{uploadOid}")
@Override
public String execute(@WebParam(name = "uploadOid") @PathParam("uploadOid") String uploadOid) throws Exception {
    SysExprJobLogVO result = null;
    Subject subject = null;
    ObjectMapper objectMapper = new ObjectMapper();
    String exceptionMessage = "";
    try {
        Map<String, Object> dataMap = SystemExpressionJobUtils.getDecUploadOid(uploadOid);
        if (dataMap == null || StringUtils.isBlank((String) dataMap.get("accountId")) || StringUtils.isBlank((String) dataMap.get("sysExprJobOid"))) {
            log.error("no data accountId / sysExprJobOid");
            result = new SysExprJobLogVO();
            result.setFaultMsg("no data accountId / sysExprJobOid");
            return objectMapper.writeValueAsString(result);
        }
        String accountId = (String) dataMap.get("accountId");
        String sysExprJobOid = (String) dataMap.get("sysExprJobOid");
        ShiroLoginSupport loginSupport = new ShiroLoginSupport();
        subject = loginSupport.forceCreateLoginSubject(accountId);
        result = SystemExpressionJobUtils.executeJobForManual(sysExprJobOid);
    } catch (ServiceException se) {
        se.printStackTrace();
        exceptionMessage = se.getMessage().toString();
    } catch (Exception e) {
        e.printStackTrace();
        if (e.getMessage() == null) {
            exceptionMessage = e.toString();
        } else {
            exceptionMessage = e.getMessage().toString();
        }
    } finally {
        if (result == null) {
            result = new SysExprJobLogVO();
        }
        if (subject != null) {
            subject.logout();
        }
        if (!StringUtils.isBlank(exceptionMessage) && StringUtils.isBlank(result.getFaultMsg())) {
            result.setFaultMsg(exceptionMessage);
        }
    }
    return objectMapper.writeValueAsString(result);
}
Also used : ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) SysExprJobLogVO(com.netsteadfast.greenstep.vo.SysExprJobLogVO) Subject(org.apache.shiro.subject.Subject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) ShiroLoginSupport(com.netsteadfast.greenstep.sys.ShiroLoginSupport) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 4 with WebMethod

use of javax.jws.WebMethod in project bamboobsc by billchen198318.

the class KpiLogicServiceImpl method findKpis.

/**
	 * for TEST
	 * 這是測試 WS REST 用的  metod , 暴露 KPIs 主檔資料
	 * 
	 * rest address: http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/
	 * 
	 * json:
	 * http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/json
	 * 
	 * xml:
	 * http://127.0.0.1:8080/gsbsc-web/services/jaxrs/kpis/xml
	 * 
	 * @param format			example:	xml / json
	 * @return
	 * @throws ServiceException
	 * @throws Exception
	 */
@WebMethod
@GET
@Path("/kpis/{format}")
@Override
public String findKpis(@WebParam(name = "format") @PathParam("format") String format) throws ServiceException, Exception {
    List<KpiVO> kpis = null;
    try {
        kpis = this.kpiService.findListVOByParams(null);
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (null == kpis) {
            kpis = new ArrayList<KpiVO>();
        }
    }
    if ("json".equals(format)) {
        Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("KPIS", kpis);
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writeValueAsString(paramMap);
    }
    XStream xstream = new XStream();
    //xstream.registerConverter( new DateConverter() );
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias("KPIS", List.class);
    xstream.alias("KPI", KpiVO.class);
    return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + xstream.toXML(kpis);
}
Also used : HashMap(java.util.HashMap) XStream(com.thoughtworks.xstream.XStream) KpiVO(com.netsteadfast.greenstep.vo.KpiVO) ServiceException(com.netsteadfast.greenstep.base.exception.ServiceException) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 5 with WebMethod

use of javax.jws.WebMethod in project opentheso by miledrousset.

the class Soap method conceptToSkos.

/**
 * Web service operation
 * @param idConcept
 * @param idThesaurus
 * @return
 */
@WebMethod(operationName = "conceptToSkos")
public String conceptToSkos(@WebParam(name = "idConcept") String idConcept, @WebParam(name = "idThesaurus") String idThesaurus) {
    if (ds == null)
        return null;
    if (prefs == null)
        return null;
    ExportFromBDD exportFromBDD = new ExportFromBDD();
    exportFromBDD.setServerArk(prefs.getProperty("serverArk"));
    exportFromBDD.setServerAdress(prefs.getProperty("cheminSite"));
    String skos = exportFromBDD.exportConcept(ds, idThesaurus, idConcept).toString();
    return skos;
}
Also used : ExportFromBDD(mom.trd.opentheso.core.exports.old.ExportFromBDD) WebMethod(javax.jws.WebMethod)

Aggregations

WebMethod (javax.jws.WebMethod)107 Method (java.lang.reflect.Method)18 Path (javax.ws.rs.Path)17 IOException (java.io.IOException)16 WebResult (javax.jws.WebResult)13 MessageContext (javax.xml.ws.handler.MessageContext)12 WebServiceException (javax.xml.ws.WebServiceException)11 Test (org.junit.Test)10 DataHandler (javax.activation.DataHandler)9 GET (javax.ws.rs.GET)9 Action (javax.xml.ws.Action)9 ArrayList (java.util.ArrayList)8 Oneway (javax.jws.Oneway)8 POST (javax.ws.rs.POST)8 File (java.io.File)7 InputStream (java.io.InputStream)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 QName (javax.xml.namespace.QName)6 RequestWrapper (javax.xml.ws.RequestWrapper)6 AbstractCodeGenTest (org.apache.cxf.tools.wsdlto.AbstractCodeGenTest)6