use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenerator method generateSOAPMessages.
/**
* Generates messages for a SOAPBinding
* @param method The {@link JavaMethod} to generate messages for
* @param binding The {@link com.sun.xml.ws.api.model.soap.SOAPBinding} to add the generated messages to
*/
protected void generateSOAPMessages(JavaMethodImpl method, com.sun.xml.ws.api.model.soap.SOAPBinding binding) {
boolean isDoclit = binding.isDocLit();
// Message message = portDefinitions.message().name(method.getOperation().getName().getLocalPart());
Message message = portDefinitions.message().name(method.getRequestMessageName());
extension.addInputMessageExtension(message, method);
com.sun.xml.ws.wsdl.writer.document.Part part;
BindingContext jaxbContext = model.getBindingContext();
boolean unwrappable = true;
for (ParameterImpl param : method.getRequestParameters()) {
if (isDoclit) {
if (isHeaderParameter(param))
unwrappable = false;
part = message.part().name(param.getPartName());
part.element(param.getName());
} else {
if (param.isWrapperStyle()) {
for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
part = message.part().name(childParam.getPartName());
part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
}
} else {
part = message.part().name(param.getPartName());
part.element(param.getName());
}
}
}
if (method.getMEP() != MEP.ONE_WAY) {
message = portDefinitions.message().name(method.getResponseMessageName());
extension.addOutputMessageExtension(message, method);
for (ParameterImpl param : method.getResponseParameters()) {
if (isDoclit) {
part = message.part().name(param.getPartName());
part.element(param.getName());
} else {
if (param.isWrapperStyle()) {
for (ParameterImpl childParam : ((WrapperParameter) param).getWrapperChildren()) {
part = message.part().name(childParam.getPartName());
part.type(jaxbContext.getTypeName(childParam.getXMLBridge().getTypeInfo()));
}
} else {
part = message.part().name(param.getPartName());
part.element(param.getName());
}
}
}
}
for (CheckedExceptionImpl exception : method.getCheckedExceptions()) {
QName tagName = exception.getDetailType().tagName;
String messageName = exception.getMessageName();
QName messageQName = new QName(model.getTargetNamespace(), messageName);
if (processedExceptions.contains(messageQName))
continue;
message = portDefinitions.message().name(messageName);
extension.addFaultMessageExtension(message, method, exception);
// tagName.getLocalPart());
part = message.part().name("fault");
part.element(tagName);
processedExceptions.add(messageQName);
}
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class TieHandler method createResponseMessageBuilder.
/**
* prepare objects for creating response {@link Message}
*/
private EndpointResponseMessageBuilder createResponseMessageBuilder(List<MessageFiller> fillers) {
EndpointResponseMessageBuilder tmpBodyBuilder = null;
List<ParameterImpl> rp = javaMethodModel.getResponseParameters();
for (ParameterImpl param : rp) {
ValueGetter getter = ValueGetter.get(param);
switch(param.getOutBinding().kind) {
case BODY:
if (param.isWrapperStyle()) {
if (param.getParent().getBinding().isRpcLit()) {
tmpBodyBuilder = new EndpointResponseMessageBuilder.RpcLit((WrapperParameter) param, soapVersion);
} else {
tmpBodyBuilder = new EndpointResponseMessageBuilder.DocLit((WrapperParameter) param, soapVersion);
}
} else {
tmpBodyBuilder = new EndpointResponseMessageBuilder.Bare(param, soapVersion);
}
break;
case HEADER:
fillers.add(new MessageFiller.Header(param.getIndex(), param.getXMLBridge(), getter));
break;
case ATTACHMENT:
fillers.add(MessageFiller.AttachmentFiller.createAttachmentFiller(param, getter));
break;
case UNBOUND:
break;
default:
// impossible
throw new AssertionError();
}
}
if (tmpBodyBuilder == null) {
// no parameter binds to body. we create an empty message
switch(soapVersion) {
case SOAP_11:
tmpBodyBuilder = EndpointResponseMessageBuilder.EMPTY_SOAP11;
break;
case SOAP_12:
tmpBodyBuilder = EndpointResponseMessageBuilder.EMPTY_SOAP12;
break;
default:
throw new AssertionError();
}
}
return tmpBodyBuilder;
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class JAXBContextFactory method newContext.
@Override
protected BindingContext newContext(BindingInfo bi) {
Map<String, Source> extMapping = (Map<String, Source>) bi.properties().get(OXM_XML_OVERRIDE);
Map<String, Object> properties = new HashMap<>();
Map<TypeInfo, TypeMappingInfo> map = createTypeMappings(bi.typeInfos());
// chen workaround for document-literal wrapper - new feature on eclipselink API requested
for (TypeInfo tinfo : map.keySet()) {
WrapperParameter wp = (WrapperParameter) tinfo.properties().get(WrapperParameter.class.getName());
if (wp != null) {
Class<?> wrpCls = (Class) tinfo.type;
Element javaAttributes = null;
for (ParameterImpl p : wp.getWrapperChildren()) {
Element xmlelem = findXmlElement(p.getTypeInfo().properties());
if (xmlelem != null) {
if (javaAttributes == null) {
javaAttributes = javaAttributes(wrpCls, extMapping);
}
xmlelem = (Element) javaAttributes.getOwnerDocument().importNode(xmlelem, true);
String fieldName = getFieldName(p, wrpCls);
xmlelem.setAttribute("java-attribute", fieldName);
javaAttributes.appendChild(xmlelem);
}
}
if (wrpCls.getPackage() != null)
wrpCls.getPackage().getName();
}
}
// Source src = extMapping.get("com.sun.xml.ws.test.toplink.jaxws");
// if (src != null){
// TransformerFactory tf = TransformerFactory.newInstance();
// try {
// Transformer t = tf.newTransformer();
// java.io.ByteArrayOutputStream bo = new java.io.ByteArrayOutputStream();
// StreamResult sax = new StreamResult(bo);
// t.transform(src, sax);
// System.out.println(new String(bo.toByteArray()));
// } catch (TransformerConfigurationException e) {
// e.printStackTrace();
// throw new WebServiceException(e.getMessage(), e);
// } catch (TransformerException e) {
// e.printStackTrace();
// throw new WebServiceException(e.getMessage(), e);
// }
// }
HashSet<Type> typeSet = new HashSet<>();
HashSet<TypeMappingInfo> typeList = new HashSet<>();
for (TypeMappingInfo tmi : map.values()) {
typeList.add(tmi);
typeSet.add(tmi.getType());
}
for (Class<?> clss : bi.contentClasses()) {
if (!typeSet.contains(clss) && !WrapperComposite.class.equals(clss)) {
typeSet.add(clss);
TypeMappingInfo tmi = new TypeMappingInfo();
tmi.setType(clss);
typeList.add(tmi);
}
}
TypeMappingInfo[] types = typeList.toArray(new TypeMappingInfo[0]);
if (extMapping != null) {
properties.put(OXM_XML_OVERRIDE, extMapping);
}
if (bi.getDefaultNamespace() != null) {
properties.put(OXM_XML_ELEMENT, bi.getDefaultNamespace());
}
try {
org.eclipse.persistence.jaxb.JAXBContext jaxbContext = (org.eclipse.persistence.jaxb.JAXBContext) org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(types, properties, bi.getClassLoader());
return new JAXBContextWrapper(jaxbContext, map, bi.getSEIModel());
} catch (JAXBException e) {
throw new DatabindingException(e.getMessage(), e);
}
}
use of com.sun.xml.ws.model.ParameterImpl in project metro-jax-ws by eclipse-ee4j.
the class StubHandler method buildResponseBuilder.
ResponseBuilder buildResponseBuilder(JavaMethodImpl method, ValueSetterFactory setterFactory) {
// prepare objects for processing response
List<ParameterImpl> rp = method.getResponseParameters();
List<ResponseBuilder> builders = new ArrayList<>();
for (ParameterImpl param : rp) {
ValueSetter setter;
switch(param.getOutBinding().kind) {
case BODY:
if (param.isWrapperStyle()) {
if (param.getParent().getBinding().isRpcLit())
builders.add(new ResponseBuilder.RpcLit((WrapperParameter) param, setterFactory));
else
builders.add(new ResponseBuilder.DocLit((WrapperParameter) param, setterFactory));
} else {
setter = setterFactory.get(param);
builders.add(new ResponseBuilder.Body(param.getXMLBridge(), setter));
}
break;
case HEADER:
setter = setterFactory.get(param);
builders.add(new ResponseBuilder.Header(soapVersion, param, setter));
break;
case ATTACHMENT:
setter = setterFactory.get(param);
builders.add(ResponseBuilder.AttachmentBuilder.createAttachmentBuilder(param, setter));
break;
case UNBOUND:
setter = setterFactory.get(param);
builders.add(new ResponseBuilder.NullSetter(setter, ResponseBuilder.getVMUninitializedValue(param.getTypeInfo().type)));
break;
default:
throw new AssertionError();
}
}
ResponseBuilder rb;
switch(builders.size()) {
case 0:
rb = ResponseBuilder.NONE;
break;
case 1:
rb = builders.get(0);
break;
default:
rb = new ResponseBuilder.Composite(builders);
}
return rb;
}
use of com.sun.xml.ws.model.ParameterImpl 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;
}
Aggregations