use of com.sun.xml.ws.model.WrapperParameter in project metro-jax-ws by eclipse-ee4j.
the class TieHandler method createArgumentsBuilder.
/**
* It builds EndpointArgumentsBuilder which converts request {@link Message} to endpoint method's invocation
* arguments Object[]
*
* @return EndpointArgumentsBuilder
*/
private EndpointArgumentsBuilder createArgumentsBuilder() {
EndpointArgumentsBuilder argsBuilder;
List<ParameterImpl> rp = javaMethodModel.getRequestParameters();
List<EndpointArgumentsBuilder> builders = new ArrayList<>();
for (ParameterImpl param : rp) {
EndpointValueSetter setter = EndpointValueSetter.get(param);
switch(param.getInBinding().kind) {
case BODY:
if (param.isWrapperStyle()) {
if (param.getParent().getBinding().isRpcLit())
builders.add(new EndpointArgumentsBuilder.RpcLit((WrapperParameter) param));
else
builders.add(new EndpointArgumentsBuilder.DocLit((WrapperParameter) param, Mode.OUT));
} else {
builders.add(new EndpointArgumentsBuilder.Body(param.getXMLBridge(), setter));
}
break;
case HEADER:
builders.add(new EndpointArgumentsBuilder.Header(soapVersion, param, setter));
break;
case ATTACHMENT:
builders.add(EndpointArgumentsBuilder.AttachmentBuilder.createAttachmentBuilder(param, setter));
break;
case UNBOUND:
builders.add(new EndpointArgumentsBuilder.NullSetter(setter, EndpointArgumentsBuilder.getVMUninitializedValue(param.getTypeInfo().type)));
break;
default:
throw new AssertionError();
}
}
// creates {@link Holder} arguments for OUT parameters
List<ParameterImpl> resp = javaMethodModel.getResponseParameters();
for (ParameterImpl param : resp) {
if (param.isWrapperStyle()) {
WrapperParameter wp = (WrapperParameter) param;
List<ParameterImpl> children = wp.getWrapperChildren();
for (ParameterImpl p : children) {
if (p.isOUT() && p.getIndex() != -1) {
EndpointValueSetter setter = EndpointValueSetter.get(p);
builders.add(new EndpointArgumentsBuilder.NullSetter(setter, null));
}
}
} else if (param.isOUT() && param.getIndex() != -1) {
EndpointValueSetter setter = EndpointValueSetter.get(param);
builders.add(new EndpointArgumentsBuilder.NullSetter(setter, null));
}
}
switch(builders.size()) {
case 0:
argsBuilder = EndpointArgumentsBuilder.NONE;
break;
case 1:
argsBuilder = builders.get(0);
break;
default:
argsBuilder = new EndpointArgumentsBuilder.Composite(builders);
}
return argsBuilder;
}
use of com.sun.xml.ws.model.WrapperParameter in project metro-jax-ws by eclipse-ee4j.
the class ServiceArtifactSchemaGenerator method initWrappersSchemaWithImports.
// All the imports have to go first ...
private HashMap<String, Schema> initWrappersSchemaWithImports(List<WrapperParameter> wrappers) {
Object o = model.databindingInfo().properties().get(RuntimeModeler.DocWrappeeNamespapceQualified);
boolean wrappeeQualified = (o instanceof Boolean) ? ((Boolean) o) : false;
HashMap<String, Schema> xsds = new HashMap<>();
HashMap<String, Set<String>> imports = new HashMap<>();
for (WrapperParameter wp : wrappers) {
String tns = wp.getName().getNamespaceURI();
Schema xsd = xsds.get(tns);
if (xsd == null) {
xsd = create(tns);
xsd.targetNamespace(tns);
if (wrappeeQualified)
xsd._attribute("elementFormDefault", "qualified");
xsds.put(tns, xsd);
}
for (ParameterImpl p : wp.getWrapperChildren()) {
String nsToImport = (p.getBinding().isBody()) ? bodyParamNS(p) : null;
if (nsToImport != null && !nsToImport.equals(tns) && !nsToImport.equals("http://www.w3.org/2001/XMLSchema")) {
Set<String> importSet = imports.computeIfAbsent(tns, k -> new HashSet<>());
importSet.add(nsToImport);
}
}
}
for (Entry<String, Set<String>> entry : imports.entrySet()) {
String tns = entry.getKey();
Set<String> importSet = entry.getValue();
Schema xsd = xsds.get(tns);
for (String nsToImport : importSet) xsd._namespace(nsToImport, true);
for (String nsToImport : importSet) {
com.sun.xml.ws.wsdl.writer.document.xsd.Import imp = xsd._import();
imp.namespace(nsToImport);
}
}
return xsds;
}
use of com.sun.xml.ws.model.WrapperParameter in project metro-jax-ws by eclipse-ee4j.
the class ServiceArtifactSchemaGenerator method generate.
public void generate(SchemaOutputResolver resolver) {
xsdResolver = resolver;
List<WrapperParameter> wrappers = new ArrayList<>();
for (JavaMethodImpl method : model.getJavaMethods()) {
if (method.getBinding().isRpcLit())
continue;
for (ParameterImpl p : method.getRequestParameters()) {
if (p instanceof WrapperParameter) {
if (WrapperComposite.class.equals((p.getTypeInfo().type))) {
wrappers.add((WrapperParameter) p);
}
}
}
for (ParameterImpl p : method.getResponseParameters()) {
if (p instanceof WrapperParameter) {
if (WrapperComposite.class.equals((p.getTypeInfo().type))) {
wrappers.add((WrapperParameter) p);
}
}
}
}
if (wrappers.isEmpty())
return;
HashMap<String, Schema> xsds = initWrappersSchemaWithImports(wrappers);
postInit(xsds);
for (WrapperParameter wp : wrappers) {
String tns = wp.getName().getNamespaceURI();
Schema xsd = xsds.get(tns);
Element e = xsd._element(Element.class);
e._attribute("name", wp.getName().getLocalPart());
e.type(wp.getName());
ComplexType ct = xsd._element(ComplexType.class);
ct._attribute("name", wp.getName().getLocalPart());
ExplicitGroup sq = ct.sequence();
for (ParameterImpl p : wp.getWrapperChildren()) if (p.getBinding().isBody())
addChild(sq, p);
}
for (Schema xsd : xsds.values()) xsd.commit();
}
use of com.sun.xml.ws.model.WrapperParameter in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateSOAP12BindingOperation.
protected void generateSOAP12BindingOperation(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());
ArrayList<ParameterImpl> bodyParams = new ArrayList<>();
ArrayList<ParameterImpl> headerParams = new ArrayList<>();
splitParameters(bodyParams, headerParams, method.getRequestParameters());
SOAPBinding soapBinding = method.getBinding();
String soapAction = soapBinding.getSOAPAction();
if (soapAction != null) {
operation.soap12Operation().soapAction(soapAction);
}
// input
TypedXmlWriter input = operation.input();
extension.addBindingOperationInputExtension(input, method);
com.sun.xml.ws.wsdl.writer.document.soap12.BodyType body = input._element(com.sun.xml.ws.wsdl.writer.document.soap12.Body.class);
boolean isRpc = soapBinding.getStyle().equals(Style.RPC);
if (soapBinding.getUse().equals(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("");
}
generateSOAP12Headers(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(com.sun.xml.ws.wsdl.writer.document.soap12.Body.class);
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("");
}
QName responseMessage = new QName(targetNamespace, method.getResponseMessageName());
generateSOAP12Headers(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);
com.sun.xml.ws.wsdl.writer.document.soap12.SOAPFault soapFault = fault._element(com.sun.xml.ws.wsdl.writer.document.soap12.SOAPFault.class).name(exception.getMessageName());
soapFault.use(LITERAL);
}
}
Aggregations