use of org.apache.axis.encoding.TypeMapping in project tomee by apache.
the class SeiFactoryImpl method initialize.
void initialize(Object serviceImpl, ClassLoader classLoader) throws ClassNotFoundException {
this.serviceImpl = serviceImpl;
Class serviceEndpointBaseClass = classLoader.loadClass(serviceEndpointClassName);
serviceEndpointClass = enhanceServiceEndpointInterface(serviceEndpointBaseClass, classLoader);
Class[] constructorTypes = new Class[] { classLoader.loadClass(GenericServiceEndpoint.class.getName()) };
this.constructor = FastClass.create(serviceEndpointClass).getConstructor(constructorTypes);
this.handlerInfoChainFactory = new HandlerInfoChainFactory(handlerInfos);
sortedOperationInfos = new OperationInfo[FastClass.create(serviceEndpointClass).getMaxIndex() + 1];
String encodingStyle = "";
for (int i = 0; i < operationInfos.length; i++) {
OperationInfo operationInfo = operationInfos[i];
Signature signature = operationInfo.getSignature();
MethodProxy methodProxy = MethodProxy.find(serviceEndpointClass, signature);
if (methodProxy == null) {
throw new ServerRuntimeException("No method proxy for operationInfo " + signature);
}
int index = methodProxy.getSuperIndex();
sortedOperationInfos[index] = operationInfo;
if (operationInfo.getOperationDesc().getUse() == Use.ENCODED) {
encodingStyle = org.apache.axis.Constants.URI_SOAP11_ENC;
}
}
// register our type descriptors
Service service = ((ServiceImpl) serviceImpl).getService();
AxisEngine axisEngine = service.getEngine();
TypeMappingRegistry typeMappingRegistry = axisEngine.getTypeMappingRegistry();
TypeMapping typeMapping = typeMappingRegistry.getOrMakeTypeMapping(encodingStyle);
typeMapping.register(BigInteger.class, Constants.XSD_UNSIGNEDLONG, new SimpleSerializerFactory(BigInteger.class, Constants.XSD_UNSIGNEDLONG), new SimpleDeserializerFactory(BigInteger.class, Constants.XSD_UNSIGNEDLONG));
typeMapping.register(URI.class, Constants.XSD_ANYURI, new SimpleSerializerFactory(URI.class, Constants.XSD_ANYURI), new SimpleDeserializerFactory(URI.class, Constants.XSD_ANYURI));
// It is essential that the types be registered before the typeInfos create the serializer/deserializers.
for (Iterator iter = typeInfo.iterator(); iter.hasNext(); ) {
TypeInfo info = (TypeInfo) iter.next();
TypeDesc.registerTypeDescForClass(info.getClazz(), info.buildTypeDesc());
}
TypeInfo.register(typeInfo, typeMapping);
}
use of org.apache.axis.encoding.TypeMapping in project Lucee by lucee.
the class BeanDeserializer method getDeserializer.
/**
* Get the Deserializer for the attribute or child element.
* @param xmlType QName of the attribute/child element or null if not known.
* @param javaType Class of the corresponding property
* @param href String is the value of the href attribute, which is used
* to determine whether the child element is complete or an
* href to another element.
* @param context DeserializationContext
* @return Deserializer or null if not found.
*/
protected Deserializer getDeserializer(QName xmlType, Class javaType, String href, DeserializationContext context) {
if (javaType.isArray()) {
context.setDestinationClass(javaType);
}
// See if we have a cached deserializer
if (cacheStringDSer != null) {
if (String.class.equals(javaType) && href == null && (cacheXMLType == null && xmlType == null || cacheXMLType != null && cacheXMLType.equals(xmlType))) {
cacheStringDSer.reset();
return cacheStringDSer;
}
}
Deserializer dSer = null;
if (xmlType != null && href == null) {
// Use the xmlType to get the deserializer.
dSer = context.getDeserializerForType(xmlType);
} else {
// If the xmlType is not set, get a default xmlType
TypeMapping tm = context.getTypeMapping();
QName defaultXMLType = tm.getTypeQName(javaType);
// not have an xsi:type.
if (href == null) {
dSer = context.getDeserializer(javaType, defaultXMLType);
} else {
dSer = new DeserializerImpl();
context.setDestinationClass(javaType);
dSer.setDefaultType(defaultXMLType);
}
}
if (javaType.equals(String.class) && dSer instanceof SimpleDeserializer) {
cacheStringDSer = (SimpleDeserializer) dSer;
cacheXMLType = xmlType;
}
return dSer;
}
use of org.apache.axis.encoding.TypeMapping in project tomee by apache.
the class JavaServiceDescBuilder method createServiceDesc.
public JavaServiceDesc createServiceDesc() throws OpenEJBException {
Class serviceEndpointInterface;
try {
serviceEndpointInterface = classLoader.loadClass(serviceInfo.serviceEndpointInterface);
} catch (ClassNotFoundException e) {
throw new OpenEJBException("Unable to load the service endpoint interface " + serviceInfo.serviceEndpointInterface, e);
}
JavaServiceDesc serviceDesc = new JavaServiceDesc();
serviceDesc.setName(serviceInfo.name);
serviceDesc.setEndpointURL(serviceInfo.endpointURL);
serviceDesc.setWSDLFile(serviceInfo.wsdlFile);
BindingStyle bindingStyle = serviceInfo.defaultBindingStyle;
switch(bindingStyle) {
case RPC_ENCODED:
serviceDesc.setStyle(Style.RPC);
serviceDesc.setUse(Use.ENCODED);
break;
case RPC_LITERAL:
serviceDesc.setStyle(Style.RPC);
serviceDesc.setUse(Use.LITERAL);
break;
case DOCUMENT_ENCODED:
serviceDesc.setStyle(Style.DOCUMENT);
serviceDesc.setUse(Use.ENCODED);
break;
case DOCUMENT_LITERAL:
serviceDesc.setStyle(Style.DOCUMENT);
serviceDesc.setUse(Use.LITERAL);
break;
case DOCUMENT_LITERAL_WRAPPED:
serviceDesc.setStyle(Style.WRAPPED);
serviceDesc.setUse(Use.LITERAL);
break;
}
// Operations
for (JaxRpcOperationInfo operationInfo : serviceInfo.operations) {
OperationDesc operationDesc = buildOperationDesc(operationInfo, serviceEndpointInterface);
serviceDesc.addOperationDesc(operationDesc);
}
// Type mapping registry
TypeMappingRegistryImpl typeMappingRegistry = new TypeMappingRegistryImpl();
typeMappingRegistry.doRegisterFromVersion("1.3");
serviceDesc.setTypeMappingRegistry(typeMappingRegistry);
// Type mapping
TypeMapping typeMapping = typeMappingRegistry.getOrMakeTypeMapping(serviceDesc.getUse().getEncoding());
serviceDesc.setTypeMapping(typeMapping);
// Types
for (JaxRpcTypeInfo type : serviceInfo.types) {
registerType(type, typeMapping);
}
return new ReadOnlyServiceDesc(serviceDesc);
}
use of org.apache.axis.encoding.TypeMapping in project tomee by apache.
the class AxisWsContainerTest method testInvokeSOAP.
public void testInvokeSOAP() throws Exception {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
JavaServiceDesc serviceDesc = new JavaServiceDesc();
serviceDesc.setEndpointURL("http://127.0.0.1:8080/axis/services/echo");
// serviceDesc.setWSDLFile(portInfo.getWsdlURL().toExternalForm());
serviceDesc.setStyle(Style.RPC);
serviceDesc.setUse(Use.ENCODED);
TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
tmr.doRegisterFromVersion("1.3");
TypeMapping typeMapping = tmr.getOrMakeTypeMapping(serviceDesc.getUse().getEncoding());
serviceDesc.setTypeMappingRegistry(tmr);
serviceDesc.setTypeMapping(typeMapping);
OperationDesc op = new OperationDesc();
op.setName("echoString");
op.setStyle(Style.RPC);
op.setUse(Use.ENCODED);
Class beanClass = EchoBean.class;
op.setMethod(beanClass.getMethod("echoString", String.class));
ParameterDesc parameter = new ParameterDesc(new QName("http://ws.apache.org/echosample", "in0"), ParameterDesc.IN, typeMapping.getTypeQName(String.class), String.class, false, false);
op.addParameter(parameter);
serviceDesc.addOperationDesc(op);
serviceDesc.getOperations();
ReadOnlyServiceDesc sd = new ReadOnlyServiceDesc(serviceDesc);
Class pojoClass = cl.loadClass("org.apache.openejb.server.axis.EchoBean");
RPCProvider provider = new PojoProvider();
SOAPService service = new SOAPService(null, provider, null);
service.setServiceDescription(sd);
service.setOption("className", "org.apache.openejb.server.axis.EchoBean");
URL wsdlURL = new URL("http://fake/echo.wsdl");
URI location = new URI(serviceDesc.getEndpointURL());
Map wsdlMap = new HashMap();
AxisWsContainer container = new AxisWsContainer(wsdlURL, service, wsdlMap, cl);
InputStream in = cl.getResourceAsStream("echoString-req.txt");
try {
AxisRequest req = new AxisRequest(504, "text/xml; charset=utf-8", new ServletIntputStreamAdapter(in), HttpRequest.Method.GET, new HashMap<String, String>(), location, new HashMap<String, String>(), "127.0.0.1");
ByteArrayOutputStream out = new ByteArrayOutputStream();
AxisResponse res = new AxisResponse("text/xml; charset=utf-8", "127.0.0.1", null, null, 8080, new ServletOutputStreamAdapter(out));
req.setAttribute(WsConstants.POJO_INSTANCE, pojoClass.newInstance());
container.onMessage(req, res);
out.flush();
// log.debug(new String(out.toByteArray()));
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ignore) {
// ignore
}
}
}
}
Aggregations