WebParam webParam = extractAnnotation(parameterCounter, WebParam.class); if (webParam != null) { paramName = webParam.name(); } else { LOGGER.warn("Method " + method.getName() + " parameter " + parameterCounter + " has no @WebParam annotation");
private QName getPartName(OperationInfo op, Method method, int paramNumber, MessageInfo mi, String prefix, boolean isIn) { int partIndex = getPartIndex(method, paramNumber, isIn); method = getDeclaredMethod(method); WebParam param = getWebParam(method, paramNumber); String tns = mi.getName().getNamespaceURI(); String local = null; if (param != null) { if (Boolean.TRUE.equals(isRPC(method)) || isDocumentBare(method) || param.header()) { local = param.partName(); } if (local == null || local.length() == 0) { local = param.name(); } } if (local == null || local.length() == 0) { if (Boolean.TRUE.equals(isRPC(method)) || !Boolean.FALSE.equals(isWrapped(method))) { local = getDefaultLocalName(op, method, paramNumber, partIndex, prefix); } else { local = getOperationName(op.getInterface(), method).getLocalPart(); } } return new QName(tns, local); }
if (param != null) { tns = param.targetNamespace(); local = param.name();
private boolean isMethodMatch(Node node, WebParam param) { boolean found = false; String nNS = node.getNamespaceURI(); if (nNS != null) { if (param.name().equals(node.getLocalName()) && nNS.equals(param.targetNamespace())) { found = true; } } else if (param.name().equals(node.getLocalName())) { found = true; } return found; }
public static WebParam getWebParam(Method method, String paraName) { Annotation[][] anno = getPrivParameterAnnotations(method); int count = method.getParameterTypes().length; for (int i = 0; i < count; i++) { for (Annotation ann : anno[i]) { if (ann.annotationType() == WebParam.class) { WebParam webParam = (WebParam)ann; if (paraName.equals(webParam.name())) { return webParam; } } } } return null; }
public static WebParam getWebParam(Method method, String paraName) { Annotation[][] anno = getPrivParameterAnnotations(method); int count = method.getParameterTypes().length; for (int i = 0; i < count; i++) { for (Annotation ann : anno[i]) { if (ann.annotationType() == WebParam.class) { WebParam webParam = (WebParam)ann; if (paraName.equals(webParam.name())) { return webParam; } } } } return null; }
public static WebParam getWebParam(Method method, String paraName) { Annotation[][] anno = getPrivParameterAnnotations(method); int count = method.getParameterTypes().length; for (int i = 0; i < count; i++) { for (Annotation ann : anno[i]) { if (ann.annotationType() == WebParam.class) { WebParam webParam = (WebParam)ann; if (paraName.equals(webParam.name())) { return webParam; } } } } return null; }
/** * The element name of this web param. * * @return The element name of this web param. */ public String getElementName() { String name = isHeader() ? "" : getBaseParamName(); if ((annotation != null) && (annotation.name() != null) && (!"".equals(annotation.name()))) { name = annotation.name(); } else if (!isHeader() && isImplicitSchemaElement()) { name = this.method.getSimpleName().toString(); } return name; }
/** * The element name of this web param. * * @return The element name of this web param. */ public String getElementName() { String name = isHeader() ? "" : getBaseParamName(); if ((annotation != null) && (annotation.name() != null) && (!"".equals(annotation.name()))) { name = annotation.name(); } else if (!isHeader() && isImplicitSchemaElement()) { name = this.method.getSimpleName(); } return name; }
private void writeRequestToContext(Object payload) { Method method = getMethod(); Object[] args = new Object[method.getParameterTypes().length]; Collection<WebParam> annotations = getWebParamAnnotations(method); int i = 0; for (WebParam wp : annotations) { args[i++] = getAttributeFromWrapper(payload, wp.name()); } msgContext.put(ObjectMessageContext.METHOD_PARAMETERS, args); }
private Object buildPayloadFromRequest(Object[] args) { RequestWrapper ann = getMethod().getAnnotation(RequestWrapper.class); assert ann != null : "failed to get request wrapper annotation"; Object wrapper = createWrapperInstance(ann.className()); int argIndex = 0; Collection<WebParam> annotations = getWebParamAnnotations(getMethod()); for (WebParam wp : annotations) { setWrapperValue(wrapper, wp.name(), args[argIndex++]); } return wrapper; }
private QName getPartName(OperationInfo op, Method method, int paramNumber, MessageInfo mi, String prefix, boolean isIn) { int partIndex = getPartIndex(method, paramNumber, isIn); method = getDeclaredMethod(method); WebParam param = getWebParam(method, paramNumber); String tns = mi.getName().getNamespaceURI(); String local = null; if (param != null) { if (Boolean.TRUE.equals(isRPC(method)) || isDocumentBare(method) || param.header()) { local = param.partName(); } if (local == null || local.length() == 0) { local = param.name(); } } if (local == null || local.length() == 0) { if (Boolean.TRUE.equals(isRPC(method)) || !Boolean.FALSE.equals(isWrapped(method))) { local = getDefaultLocalName(op, method, paramNumber, partIndex, prefix); } else { local = getOperationName(op.getInterface(), method).getLocalPart(); } } return new QName(tns, local); }
protected void introspectAnnotations(Annotation[] annotations, DataType targetDataType) { WebResult result = getAnnotation(annotations, WebResult.class); if (result != null) { QName name = new QName(result.targetNamespace(), result.name()); targetDataType.setLogical(new XMLType(name, null)); } WebParam param = getAnnotation(annotations, WebParam.class); if (param != null) { QName name = new QName(param.targetNamespace(), param.name()); targetDataType.setLogical(new XMLType(name, null)); } }
public String getAnnoWebParamName() { if (webParamName == null) { if (getAnnoWebParam() != null && !DescriptionUtils.isEmpty(getAnnoWebParam().name())) { webParamName = getAnnoWebParam().name(); } else if (getOperationDescription().getSoapBindingStyle() == SOAPBinding.Style.DOCUMENT && getOperationDescription().getSoapBindingParameterStyle() == SOAPBinding.ParameterStyle.BARE) { // Defaul per JSR-181 MR Sec 4.4.1, pg 19 // TODO: Validation: For BARE paramaterUse, only a single IN our INOUT paramater and a single output (either return or OUT or INOUT) is allowed // Per JSR-224, Sec 3.6.2.2, pg 37 webParamName = getOperationDescription().getOperationName(); } else { // Default per JSR-181 MR Sec 4.4.1, pg 20 // Return "argN" where N is the index of the parameter in the method signature webParamName = "arg" + parameterNumber; } } return webParamName; }
public String getAnnoWebParamName() { if (webParamName == null) { if (getAnnoWebParam() != null && !DescriptionUtils.isEmpty(getAnnoWebParam().name())) { webParamName = getAnnoWebParam().name(); } else if (getOperationDescription().getSoapBindingStyle() == SOAPBinding.Style.DOCUMENT && getOperationDescription().getSoapBindingParameterStyle() == SOAPBinding.ParameterStyle.BARE) { // Defaul per JSR-181 MR Sec 4.4.1, pg 19 // TODO: Validation: For BARE paramaterUse, only a single IN our INOUT paramater and a single output (either return or OUT or INOUT) is allowed // Per JSR-224, Sec 3.6.2.2, pg 37 webParamName = getOperationDescription().getOperationName(); } else { // Default per JSR-181 MR Sec 4.4.1, pg 20 // Return "argN" where N is the index of the parameter in the method signature webParamName = "arg" + parameterNumber; } } return webParamName; }
private static JavaLanguageVariable buildJavaVariableFromMethodParam(Method method, int paramIndex, WebParam xmlAnnotation) { JavaLanguageVariable variable = new JavaLanguageVariable(); variable.setType(GenericsUtils.getMethodGenericParameterTypes(method, paramIndex)); variable.setVariableName(xmlAnnotation.name()); variable.setRequired(true); variable.setHeader(xmlAnnotation.header()); Class<?> paramClass = method.getParameterTypes()[paramIndex]; variable.setMultiOccurs(isClassArrayOrCollection(paramClass)); return variable; }
@Override public ValidationResult validateEndpointInterface(EndpointInterface ei) { ValidationResult result = super.validateEndpointInterface(ei); EndpointInterface visited = visitedEndpoints.put(ei.getServiceName(), ei); if (visited != null) { if (visited.getTargetNamespace().equals(ei.getTargetNamespace())) { result.addError(ei.getPosition(), "Ummm... you already have a service named " + ei.getServiceName() + " at " + visited.getPosition() + ". You need to disambiguate."); } } for (WebMethod webMethod : ei.getWebMethods()) { for (WebParam webParam : webMethod.getWebParameters()) { if ((webParam.isHeader()) && ("".equals(webParam.getAnnotation(javax.jws.WebParam.class).name()))) { //todo: lift this constraint by serializing the parameter names to some file you can load for metadata... result.addError(webParam.getPosition(), "For now, Enunciate requires you to specify a 'name' on the @WebParam annotation if it's a header."); } } } return result; }
/** * This method will attach @WebParam annotation data to the <code> ParameterDescriptionComposite</code> * if the annotation was found on the parameter represented by this index in the parameter list. * * @param pdc - <code>ParameterDescriptionComposite</code> * @param order - the current index in the parameter list */ private void attachWebParamAnnotation(ParameterDescriptionComposite pdc, int order) { Annotation[] orderAnnots = paramAnnotations[order]; for (Annotation annot : orderAnnots) { if (annot instanceof WebParam) { WebParam webParam = (WebParam)annot; WebParamAnnot wpAnnot = WebParamAnnot.createWebParamAnnotImpl(); wpAnnot.setHeader(webParam.header()); wpAnnot.setMode(webParam.mode()); wpAnnot.setName(webParam.name()); wpAnnot.setPartName(webParam.partName()); wpAnnot.setTargetNamespace(webParam.targetNamespace()); pdc.setWebParamAnnot(wpAnnot); } } } }
/** * This method will attach @WebParam annotation data to the <code> ParameterDescriptionComposite</code> * if the annotation was found on the parameter represented by this index in the parameter list. * * @param pdc - <code>ParameterDescriptionComposite</code> * @param order - the current index in the parameter list */ private void attachWebParamAnnotation(ParameterDescriptionComposite pdc, int order) { Annotation[] orderAnnots = paramAnnotations[order]; for (Annotation annot : orderAnnots) { if (annot instanceof WebParam) { WebParam webParam = (WebParam)annot; WebParamAnnot wpAnnot = WebParamAnnot.createWebParamAnnotImpl(); wpAnnot.setHeader(webParam.header()); wpAnnot.setMode(webParam.mode()); wpAnnot.setName(webParam.name()); wpAnnot.setPartName(webParam.partName()); wpAnnot.setTargetNamespace(webParam.targetNamespace()); pdc.setWebParamAnnot(wpAnnot); } } } }