use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method sortMethodParameters.
/**
* Sorts the parameters for the method by their position
* @param method the {@link JavaMethod} used to sort the parameters
* @return the sorted {@link List} of parameters
*/
protected List<ParameterImpl> sortMethodParameters(JavaMethodImpl method) {
Set<ParameterImpl> paramSet = new HashSet<>();
List<ParameterImpl> sortedParams = new ArrayList<>();
if (isRpcLit(method)) {
for (ParameterImpl param : method.getRequestParameters()) {
if (param instanceof WrapperParameter) {
paramSet.addAll(((WrapperParameter) param).getWrapperChildren());
} else {
paramSet.add(param);
}
}
for (ParameterImpl param : method.getResponseParameters()) {
if (param instanceof WrapperParameter) {
paramSet.addAll(((WrapperParameter) param).getWrapperChildren());
} else {
paramSet.add(param);
}
}
} else {
paramSet.addAll(method.getRequestParameters());
paramSet.addAll(method.getResponseParameters());
}
Iterator<ParameterImpl> params = paramSet.iterator();
if (paramSet.isEmpty())
return sortedParams;
ParameterImpl param = params.next();
sortedParams.add(param);
ParameterImpl sortedParam;
int pos;
for (int i = 1; i < paramSet.size(); i++) {
param = params.next();
for (pos = 0; pos < i; pos++) {
sortedParam = sortedParams.get(pos);
if (param.getIndex() == sortedParam.getIndex() && param instanceof WrapperParameter)
break;
if (param.getIndex() < sortedParam.getIndex()) {
break;
}
}
sortedParams.add(pos, param);
}
return sortedParams;
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateSOAPHeaders.
protected void generateSOAPHeaders(TypedXmlWriter writer, List<ParameterImpl> parameters, QName message) {
for (ParameterImpl headerParam : parameters) {
Header header = writer._element(Header.class);
header.message(message);
header.part(headerParam.getPartName());
header.use(LITERAL);
}
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateSOAP12Headers.
protected void generateSOAP12Headers(TypedXmlWriter writer, List<ParameterImpl> parameters, QName message) {
for (ParameterImpl headerParam : parameters) {
com.sun.xml.ws.wsdl.writer.document.soap12.Header header = writer._element(com.sun.xml.ws.wsdl.writer.document.soap12.Header.class);
header.message(message);
header.part(headerParam.getPartName());
header.use(LITERAL);
}
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateBindingOperation.
protected void generateBindingOperation(JavaMethodImpl method, Binding binding) {
BindingOperationType operation = binding.operation().name(method.getOperationName());
extension.addBindingOperationExtension(operation, method);
String targetNamespace = model.getTargetNamespace();
QName requestMessage = new QName(targetNamespace, method.getOperationName());
List<ParameterImpl> bodyParams = new ArrayList<>();
List<ParameterImpl> headerParams = new ArrayList<>();
splitParameters(bodyParams, headerParams, method.getRequestParameters());
SOAPBinding soapBinding = method.getBinding();
operation.soapOperation().soapAction(soapBinding.getSOAPAction());
// input
TypedXmlWriter input = operation.input();
extension.addBindingOperationInputExtension(input, method);
BodyType body = input._element(Body.class);
boolean isRpc = soapBinding.getStyle().equals(Style.RPC);
if (soapBinding.getUse() == Use.LITERAL) {
body.use(LITERAL);
if (headerParams.size() > 0) {
if (bodyParams.size() > 0) {
ParameterImpl param = bodyParams.iterator().next();
if (isRpc) {
StringBuilder parts = new StringBuilder();
int i = 0;
for (ParameterImpl parameter : ((WrapperParameter) param).getWrapperChildren()) {
if (i++ > 0)
parts.append(' ');
parts.append(parameter.getPartName());
}
body.parts(parts.toString());
} else {
body.parts(param.getPartName());
}
} else {
body.parts("");
}
generateSOAPHeaders(input, headerParams, requestMessage);
}
if (isRpc) {
body.namespace(method.getRequestParameters().iterator().next().getName().getNamespaceURI());
}
} else {
// TODO localize this
throw new WebServiceException("encoded use is not supported");
}
if (method.getMEP() != MEP.ONE_WAY) {
// output
bodyParams.clear();
headerParams.clear();
splitParameters(bodyParams, headerParams, method.getResponseParameters());
TypedXmlWriter output = operation.output();
extension.addBindingOperationOutputExtension(output, method);
body = output._element(Body.class);
body.use(LITERAL);
if (headerParams.size() > 0) {
StringBuilder parts = new StringBuilder();
if (bodyParams.size() > 0) {
ParameterImpl param = bodyParams.iterator().hasNext() ? bodyParams.iterator().next() : null;
if (param != null) {
if (isRpc) {
int i = 0;
for (ParameterImpl parameter : ((WrapperParameter) param).getWrapperChildren()) {
if (i++ > 0) {
parts.append(" ");
}
parts.append(parameter.getPartName());
}
} else {
parts = new StringBuilder(param.getPartName());
}
}
}
body.parts(parts.toString());
QName responseMessage = new QName(targetNamespace, method.getResponseMessageName());
generateSOAPHeaders(output, headerParams, responseMessage);
}
if (isRpc) {
body.namespace(method.getRequestParameters().iterator().next().getName().getNamespaceURI());
}
}
for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
Fault fault = operation.fault().name(exception.getMessageName());
extension.addBindingOperationFaultExtension(fault, method, exception);
SOAPFault soapFault = fault._element(SOAPFault.class).name(exception.getMessageName());
soapFault.use(LITERAL);
}
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateRpcParameterOrder.
/**
* Generates the parameterOrder for a PortType operation
* @param operation the operation to generate the parameterOrder for
* @param method the {@link JavaMethod} to generate the parameterOrder from
*/
protected void generateRpcParameterOrder(Operation operation, JavaMethodImpl method) {
String partName;
StringBuilder paramOrder = new StringBuilder();
Set<String> partNames = new HashSet<>();
List<ParameterImpl> sortedParams = sortMethodParameters(method);
int i = 0;
for (ParameterImpl parameter : sortedParams) {
if (parameter.getIndex() >= 0) {
partName = parameter.getPartName();
if (!partNames.contains(partName)) {
if (i++ > 0)
paramOrder.append(' ');
paramOrder.append(partName);
partNames.add(partName);
}
}
}
if (i > 1) {
operation.parameterOrder(paramOrder.toString());
}
}
Aggregations