use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLModeler method getRequestParameters.
private List<Parameter> getRequestParameters(Request request, List<String> parameterList) {
Message inputMessage = getInputMessage();
// there is no input message, return zero parameters
if (inputMessage != null && !inputMessage.parts().hasNext()) {
return new ArrayList<>();
}
List<Parameter> inParameters = null;
QName reqBodyName;
Block reqBlock;
JAXBType jaxbReqType;
boolean unwrappable = isUnwrappable();
boolean doneSOAPBody = false;
// setup request parameters
for (String inParamName : parameterList) {
MessagePart part = inputMessage.getPart(inParamName);
if (part == null) {
continue;
}
reqBodyName = part.getDescriptor();
jaxbReqType = getJAXBType(part);
if (unwrappable) {
// So build body and header blocks and set to request and response
JAXBStructuredType jaxbRequestType = ModelerUtils.createJAXBStructureType(jaxbReqType);
reqBlock = new Block(reqBodyName, jaxbRequestType, part);
if (ModelerUtils.isBoundToSOAPBody(part)) {
request.addBodyBlock(reqBlock);
} else if (ModelerUtils.isUnbound(part)) {
request.addUnboundBlock(reqBlock);
}
inParameters = ModelerUtils.createUnwrappedParameters(jaxbRequestType, reqBlock);
for (Parameter param : inParameters) {
setCustomizedParameterName(info.portTypeOperation, inputMessage, part, param, unwrappable);
}
} else {
reqBlock = new Block(reqBodyName, jaxbReqType, part);
if (ModelerUtils.isBoundToSOAPBody(part) && !doneSOAPBody) {
doneSOAPBody = true;
request.addBodyBlock(reqBlock);
} else if (ModelerUtils.isBoundToSOAPHeader(part)) {
request.addHeaderBlock(reqBlock);
} else if (ModelerUtils.isBoundToMimeContent(part)) {
List<MIMEContent> mimeContents = getMimeContents(info.bindingOperation.getInput(), getInputMessage(), part.getName());
jaxbReqType = getAttachmentType(mimeContents, part);
// reqBlock = new Block(new QName(part.getName()), jaxbReqType);
reqBlock = new Block(jaxbReqType.getName(), jaxbReqType, part);
request.addAttachmentBlock(reqBlock);
} else if (ModelerUtils.isUnbound(part)) {
request.addUnboundBlock(reqBlock);
}
if (inParameters == null) {
inParameters = new ArrayList<>();
}
Parameter param = ModelerUtils.createParameter(part.getName(), jaxbReqType, reqBlock);
setCustomizedParameterName(info.portTypeOperation, inputMessage, part, param, false);
inParameters.add(param);
}
}
return inParameters;
}
use of com.sun.tools.ws.wsdl.document.Message in project metro-jax-ws by eclipse-ee4j.
the class WSDLModeler method createAsyncOperation.
private Operation createAsyncOperation(Operation syncOperation, StyleAndUse styleAndUse, AsyncOperationType asyncType) {
boolean isRequestResponse = info.portTypeOperation.getStyle() == OperationStyle.REQUEST_RESPONSE;
if (!isRequestResponse) {
return null;
}
// create async operations
AsyncOperation operation = new AsyncOperation(info.operation, info.bindingOperation);
// operation.setName(new QName(operation.getName().getNamespaceURI(), getAsyncOperationName(info.portTypeOperation, operation)));
if (asyncType.equals(AsyncOperationType.CALLBACK)) {
operation.setUniqueName(info.operation.getUniqueName() + "_async_callback");
} else if (asyncType.equals(AsyncOperationType.POLLING)) {
operation.setUniqueName(info.operation.getUniqueName() + "_async_polling");
}
setDocumentationIfPresent(operation, info.portTypeOperation.getDocumentation());
operation.setAsyncType(asyncType);
operation.setSOAPAction(info.operation.getSOAPAction());
boolean unwrappable = info.operation.isWrapped();
operation.setWrapped(unwrappable);
SOAPBody soapRequestBody = getSOAPRequestBody();
Message inputMessage = getInputMessage();
Request request = new Request(inputMessage, errReceiver);
SOAPBody soapResponseBody = getSOAPResponseBody();
Message outputMessage = getOutputMessage();
Response response = new Response(outputMessage, errReceiver);
// Process parameterOrder and get the parameterList
java.util.List<String> parameterList = getAsynParameterOrder();
List<Parameter> inParameters = null;
if (isOperationDocumentLiteral(styleAndUse)) {
inParameters = getRequestParameters(request, parameterList);
// re-create parameterList with unwrapped parameters
if (unwrappable) {
List<String> unwrappedParameterList = new ArrayList<>();
if (inputMessage != null) {
Iterator<MessagePart> parts = inputMessage.parts();
if (parts.hasNext()) {
MessagePart part = parts.next();
JAXBType jaxbType = getJAXBType(part);
List<JAXBProperty> memberList = jaxbType.getWrapperChildren();
Iterator<JAXBProperty> props = memberList.iterator();
while (props.hasNext()) {
JAXBProperty prop = props.next();
unwrappedParameterList.add(prop.getElementName().getLocalPart());
}
}
}
parameterList.clear();
parameterList.addAll(unwrappedParameterList);
}
} else if (isOperationRpcLiteral(styleAndUse)) {
String operationName = info.bindingOperation.getName();
Block reqBlock = null;
if (inputMessage != null) {
QName name = new QName(getRequestNamespaceURI(soapRequestBody), operationName);
RpcLitStructure rpcStruct = new RpcLitStructure(name, getJAXBModelBuilder().getJAXBModel());
rpcStruct.setJavaType(new JavaSimpleType("com.sun.xml.ws.encoding.jaxb.RpcLitPayload", null));
reqBlock = new Block(name, rpcStruct, inputMessage);
request.addBodyBlock(reqBlock);
}
inParameters = createRpcLitRequestParameters(request, parameterList, reqBlock);
}
// add response blocks, we dont need to create respnse parameters, just blocks will be fine, lets
// copy them from sync optraions
// copy the response blocks from the sync operation
Iterator<Block> blocks = info.operation.getResponse().getBodyBlocks();
while (blocks.hasNext()) {
response.addBodyBlock(blocks.next());
}
blocks = info.operation.getResponse().getHeaderBlocks();
while (blocks.hasNext()) {
response.addHeaderBlock(blocks.next());
}
blocks = info.operation.getResponse().getAttachmentBlocks();
while (blocks.hasNext()) {
response.addAttachmentBlock(blocks.next());
}
List<MessagePart> outputParts = outputMessage.getParts();
// handle headers
int numOfOutMsgParts = outputParts.size();
if (numOfOutMsgParts == 1) {
MessagePart part = outputParts.get(0);
if (isOperationDocumentLiteral(styleAndUse)) {
JAXBType type = getJAXBType(part);
operation.setResponseBean(type);
} else if (isOperationRpcLiteral(styleAndUse)) {
String operationName = info.bindingOperation.getName();
Block resBlock = info.operation.getResponse().getBodyBlocksMap().get(new QName(getResponseNamespaceURI(soapResponseBody), operationName + "Response"));
RpcLitStructure resBean = (RpcLitStructure) resBlock.getType();
List<RpcLitMember> members = resBean.getRpcLitMembers();
operation.setResponseBean(members.get(0));
}
} else {
// create response bean
String nspace = "";
QName responseBeanName = new QName(nspace, getAsyncOperationName(info.operation) + "Response");
JAXBType responseBeanType = getJAXBModelBuilder().getJAXBType(responseBeanName);
if (responseBeanType == null) {
error(info.operation.getEntity(), ModelerMessages.WSDLMODELER_RESPONSEBEAN_NOTFOUND(info.operation.getName()));
}
operation.setResponseBean(responseBeanType);
}
QName respBeanName = new QName(soapResponseBody.getNamespace(), getAsyncOperationName(info.operation) + "Response");
Block block = new Block(respBeanName, operation.getResponseBeanType(), outputMessage);
JavaType respJavaType = operation.getResponseBeanJavaType();
JAXBType respType = new JAXBType(respBeanName, respJavaType);
Parameter respParam = ModelerUtils.createParameter(info.operation.getName() + "Response", respType, block);
respParam.setParameterIndex(-1);
response.addParameter(respParam);
operation.setProperty(WSDL_RESULT_PARAMETER, respParam.getName());
int parameterOrderPosition = 0;
for (String name : parameterList) {
Parameter inParameter = ModelerUtils.getParameter(name, inParameters);
if (inParameter == null) {
if (options.isExtensionMode()) {
warning(info.operation.getEntity(), ModelerMessages.WSDLMODELER_WARNING_IGNORING_OPERATION_PART_NOT_FOUND(info.operation.getName().getLocalPart(), name));
} else {
error(info.operation.getEntity(), ModelerMessages.WSDLMODELER_ERROR_PART_NOT_FOUND(info.operation.getName().getLocalPart(), name));
}
return null;
}
request.addParameter(inParameter);
inParameter.setParameterIndex(parameterOrderPosition);
parameterOrderPosition++;
}
operation.setResponse(response);
// add callback handlerb Parameter to request
if (operation.getAsyncType().equals(AsyncOperationType.CALLBACK)) {
JavaType cbJavaType = operation.getCallBackType();
JAXBType callbackType = new JAXBType(respBeanName, cbJavaType);
Parameter cbParam = ModelerUtils.createParameter("asyncHandler", callbackType, block);
request.addParameter(cbParam);
}
operation.setRequest(request);
return operation;
}
Aggregations