use of com.sun.xml.ws.api.model.wsdl.WSDLPart in project metro-jax-ws by eclipse-ee4j.
the class AbstractSEIModelImpl method applyRpcLitParamBinding.
/**
* Applies binding related information to the RpcLitPayload. The payload map is populated correctly
* @return
* Returns attachment parameters if/any.
*/
private List<ParameterImpl> applyRpcLitParamBinding(JavaMethodImpl method, WrapperParameter wrapperParameter, WSDLBoundPortType boundPortType, Mode mode) {
QName opName = new QName(boundPortType.getPortTypeName().getNamespaceURI(), method.getOperationName());
WSDLBoundOperation bo = boundPortType.get(opName);
Map<Integer, ParameterImpl> bodyParams = new HashMap<>();
List<ParameterImpl> unboundParams = new ArrayList<>();
List<ParameterImpl> attachParams = new ArrayList<>();
for (ParameterImpl param : wrapperParameter.wrapperChildren) {
String partName = param.getPartName();
if (partName == null)
continue;
ParameterBinding paramBinding = boundPortType.getBinding(opName, partName, mode);
if (paramBinding != null) {
if (mode == Mode.IN)
param.setInBinding(paramBinding);
else if (mode == Mode.OUT || mode == Mode.INOUT)
param.setOutBinding(paramBinding);
if (paramBinding.isUnbound()) {
unboundParams.add(param);
} else if (paramBinding.isAttachment()) {
attachParams.add(param);
} else if (paramBinding.isBody()) {
if (bo != null) {
WSDLPart p = bo.getPart(param.getPartName(), mode);
if (p != null)
bodyParams.put(p.getIndex(), param);
else
bodyParams.put(bodyParams.size(), param);
} else {
bodyParams.put(bodyParams.size(), param);
}
}
}
}
wrapperParameter.clear();
for (int i = 0; i < bodyParams.size(); i++) {
ParameterImpl p = bodyParams.get(i);
wrapperParameter.addWrapperChild(p);
}
// add unbounded parts
for (ParameterImpl p : unboundParams) {
wrapperParameter.addWrapperChild(p);
}
return attachParams;
}
use of com.sun.xml.ws.api.model.wsdl.WSDLPart in project metro-jax-ws by eclipse-ee4j.
the class RuntimeModeler method processRpcMethod.
/**
* models a rpc/literal method
* @param javaMethod the runtime model <code>JavaMethod</code> instance being created
* @param methodName the name of the <code>method</code> being modeled.
* @param operationName the WSDL operation name for this <code>method</code>
* @param method the runtime model <code>JavaMethod</code> instance being created
*/
protected void processRpcMethod(JavaMethodImpl javaMethod, String methodName, String operationName, Method method) {
boolean isOneway = getAnnotation(method, Oneway.class) != null;
// use Map to build parameters in the part order when they are known.
// if part is unbound, we just put them at the end, and for that we
// use a large index (10000+) to avoid colliding with ordered ones.
// this assumes that there's no operation with # of parameters > 10000,
// but I think it's a pretty safe assumption - KK.
Map<Integer, ParameterImpl> resRpcParams = new TreeMap<>();
Map<Integer, ParameterImpl> reqRpcParams = new TreeMap<>();
// Lets take the service namespace and overwrite it with the one we get it from wsdl
String reqNamespace = targetNamespace;
String respNamespace = targetNamespace;
if (binding != null && Style.RPC.equals(binding.getBinding().getStyle())) {
QName opQName = new QName(binding.getBinding().getPortTypeName().getNamespaceURI(), operationName);
WSDLBoundOperation op = binding.getBinding().get(opQName);
if (op != null) {
// it cant be null, but lets not fail and try to work with service namespce
if (op.getRequestNamespace() != null) {
reqNamespace = op.getRequestNamespace();
}
// it cant be null, but lets not fail and try to work with service namespce
if (op.getResponseNamespace() != null) {
respNamespace = op.getResponseNamespace();
}
}
}
QName reqElementName = new QName(reqNamespace, operationName);
javaMethod.setRequestPayloadName(reqElementName);
QName resElementName = null;
if (!isOneway) {
resElementName = new QName(respNamespace, operationName + RESPONSE);
}
Class wrapperType = WrapperComposite.class;
TypeInfo typeRef = new TypeInfo(reqElementName, wrapperType);
WrapperParameter requestWrapper = new WrapperParameter(javaMethod, typeRef, Mode.IN, 0);
requestWrapper.setInBinding(ParameterBinding.BODY);
javaMethod.addParameter(requestWrapper);
WrapperParameter responseWrapper = null;
if (!isOneway) {
typeRef = new TypeInfo(resElementName, wrapperType);
responseWrapper = new WrapperParameter(javaMethod, typeRef, Mode.OUT, -1);
responseWrapper.setOutBinding(ParameterBinding.BODY);
javaMethod.addParameter(responseWrapper);
}
Class returnType = method.getReturnType();
String resultName = RETURN;
String resultTNS = targetNamespace;
String resultPartName = resultName;
boolean isResultHeader = false;
WebResult webResult = getAnnotation(method, WebResult.class);
if (webResult != null) {
isResultHeader = webResult.header();
if (webResult.name().length() > 0)
resultName = webResult.name();
if (webResult.partName().length() > 0) {
resultPartName = webResult.partName();
if (!isResultHeader)
resultName = resultPartName;
} else
resultPartName = resultName;
if (webResult.targetNamespace().length() > 0)
resultTNS = webResult.targetNamespace();
isResultHeader = webResult.header();
}
QName resultQName;
if (isResultHeader)
resultQName = new QName(resultTNS, resultName);
else
resultQName = new QName(resultName);
if (javaMethod.isAsync()) {
returnType = getAsyncReturnType(method, returnType);
}
if (!isOneway && returnType != null && returnType != void.class) {
Annotation[] rann = getAnnotations(method);
TypeInfo rTypeReference = new TypeInfo(resultQName, returnType, rann);
metadataReader.getProperties(rTypeReference.properties(), method);
rTypeReference.setGenericType(method.getGenericReturnType());
ParameterImpl returnParameter = new ParameterImpl(javaMethod, rTypeReference, Mode.OUT, -1);
returnParameter.setPartName(resultPartName);
if (isResultHeader) {
returnParameter.setBinding(ParameterBinding.HEADER);
javaMethod.addParameter(returnParameter);
rTypeReference.setGlobalElement(true);
} else {
ParameterBinding rb = getBinding(operationName, resultPartName, false, Mode.OUT);
returnParameter.setBinding(rb);
if (rb.isBody()) {
rTypeReference.setGlobalElement(false);
WSDLPart p = getPart(new QName(targetNamespace, operationName), resultPartName, Mode.OUT);
if (p == null)
resRpcParams.put(resRpcParams.size() + 10000, returnParameter);
else
resRpcParams.put(p.getIndex(), returnParameter);
} else {
javaMethod.addParameter(returnParameter);
}
}
}
// get WebParam
Class<?>[] parameterTypes = method.getParameterTypes();
Type[] genericParameterTypes = method.getGenericParameterTypes();
Annotation[][] pannotations = getParamAnnotations(method);
int pos = 0;
for (Class clazzType : parameterTypes) {
String paramName = "";
String paramNamespace = "";
String partName = "";
boolean isHeader = false;
if (javaMethod.isAsync() && AsyncHandler.class.isAssignableFrom(clazzType)) {
continue;
}
boolean isHolder = HOLDER_CLASS.isAssignableFrom(clazzType);
// set the actual type argument of Holder in the TypeReference
if (isHolder) {
if (clazzType == Holder.class)
clazzType = erasure(((ParameterizedType) genericParameterTypes[pos]).getActualTypeArguments()[0]);
}
Mode paramMode = isHolder ? Mode.INOUT : Mode.IN;
for (Annotation annotation : pannotations[pos]) {
if (annotation.annotationType() == jakarta.jws.WebParam.class) {
jakarta.jws.WebParam webParam = (jakarta.jws.WebParam) annotation;
paramName = webParam.name();
partName = webParam.partName();
isHeader = webParam.header();
WebParam.Mode mode = webParam.mode();
paramNamespace = webParam.targetNamespace();
if (isHolder && mode == Mode.IN)
mode = Mode.INOUT;
paramMode = mode;
break;
}
}
if (paramName.length() == 0) {
paramName = "arg" + pos;
}
if (partName.length() == 0) {
partName = paramName;
} else if (!isHeader) {
paramName = partName;
}
if (partName.length() == 0) {
partName = paramName;
}
QName paramQName;
if (!isHeader) {
// its rpclit body param, set namespace to ""
paramQName = new QName("", paramName);
} else {
if (paramNamespace.length() == 0)
paramNamespace = targetNamespace;
paramQName = new QName(paramNamespace, paramName);
}
typeRef = new TypeInfo(paramQName, clazzType, pannotations[pos]);
metadataReader.getProperties(typeRef.properties(), method, pos);
typeRef.setGenericType(genericParameterTypes[pos]);
ParameterImpl param = new ParameterImpl(javaMethod, typeRef, paramMode, pos++);
param.setPartName(partName);
if (paramMode == Mode.INOUT) {
ParameterBinding pb = getBinding(operationName, partName, isHeader, Mode.IN);
param.setInBinding(pb);
pb = getBinding(operationName, partName, isHeader, Mode.OUT);
param.setOutBinding(pb);
} else {
if (isHeader) {
typeRef.setGlobalElement(true);
param.setBinding(ParameterBinding.HEADER);
} else {
ParameterBinding pb = getBinding(operationName, partName, false, paramMode);
param.setBinding(pb);
}
}
if (param.getInBinding().isBody()) {
typeRef.setGlobalElement(false);
if (!param.isOUT()) {
WSDLPart p = getPart(new QName(targetNamespace, operationName), partName, Mode.IN);
if (p == null)
reqRpcParams.put(reqRpcParams.size() + 10000, param);
else
reqRpcParams.put(param.getIndex(), param);
}
if (!param.isIN()) {
if (isOneway) {
throw new RuntimeModelerException("runtime.modeler.oneway.operation.no.out.parameters", portClass.getCanonicalName(), methodName);
}
WSDLPart p = getPart(new QName(targetNamespace, operationName), partName, Mode.OUT);
if (p == null)
resRpcParams.put(resRpcParams.size() + 10000, param);
else
resRpcParams.put(p.getIndex(), param);
}
} else {
javaMethod.addParameter(param);
}
}
for (ParameterImpl p : reqRpcParams.values()) requestWrapper.addWrapperChild(p);
for (ParameterImpl p : resRpcParams.values()) responseWrapper.addWrapperChild(p);
processExceptions(javaMethod, method);
}
Aggregations