/** * This method overrides the Axis2 listing agent's computation of the * service name. */ @Override public String extractServiceName(String urlString) { String serviceName = findAxisServiceName(urlString); setContextRoot(urlString, serviceName); return serviceName; }
public void init(ConfigurationContext configContext) { this.tmpconfigContext = configContext; //try { //super.init(DUMMY_CONFIG); //init(DUMMY_CONFIG); //} catch (ServletException e) { // throw new RuntimeException(e); //} agent = new TuscanyListingAgent(configContext); }
public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) { return new Axis2ServiceBindingProvider(extensionPoints, endpoint, servletHost); }
public static void createAxisServiceProviders(AxisService axisService, RuntimeEndpoint endpoint, WebServiceBinding wsBinding, ExtensionPointRegistry extensionPoints) { for (Iterator<?> i = axisService.getOperations(); i.hasNext();) { AxisOperation axisOp = (AxisOperation)i.next(); Operation op = getOperation(axisOp, wsBinding); if (op != null) { if (op.isNonBlocking()) { axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY); } else { axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT); } MessageReceiver msgrec = null; TuscanyServiceProvider serviceProvider = new TuscanyServiceProvider(extensionPoints, endpoint, wsBinding, op); if (op.isNonBlocking()) { msgrec = new Axis2ServiceInMessageReceiver(serviceProvider); } else { msgrec = new Axis2ServiceInOutSyncMessageReceiver(serviceProvider); } axisOp.setMessageReceiver(msgrec); } } }
private void createAxisService(String endpointURL, Port port) throws AxisFault { AxisService axisService; if (wsBinding.getGeneratedWSDLDocument() != null) { axisService = Axis2EngineIntegration.createWSDLAxisService(endpointURL, port, wsBinding); } else { axisService = Axis2EngineIntegration.createJavaAxisService(endpointURL, configContext, service); } Axis2EngineIntegration.createAxisServiceProviders(axisService, endpoint, wsBinding, extensionPoints); configContext.getAxisConfiguration().addService(axisService); } }
public Invoker createInvoker(Operation operation) { Options options = new Options(); org.apache.axis2.addressing.EndpointReference epTo = getWSATOEPR(wsBinding); if (epTo != null) { options.setTo(epTo); String soapAction = getSOAPAction(operationName); if (soapAction != null && soapAction.length() > 1) { options.setAction(soapAction); return new Axis2ReferenceBindingInvoker(endpointReference, serviceClient, wsdlOperationQName, options, soapFactory, wsBinding);
public void start() { try { createAxisService(deployedURI, wsdlPort); // Apply the configuration from any other policies for (PolicyProvider pp : endpoint.getPolicyProviders()) { pp.configureBinding(this); } if (deployedURI.startsWith("http://") || deployedURI.startsWith("https://") || deployedURI.startsWith("/")) { Axis2ServiceServlet servlet = new Axis2ServiceServlet(); servlet.init(configContext); if (httpSecurityContext.isSSLEnabled()){ deployedURI = servletHost.addServletMapping(endpointURI, servlet, httpSecurityContext); } else { deployedURI = servletHost.addServletMapping(endpointURI, servlet); } } endpoint.setDeployedURI(deployedURI); } catch (AxisFault e) { throw new RuntimeException(e); } }
/** * Override the AxisServlet doGet to use the TuscanyListingAgent for ?wsdl */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { initContextRoot(request); String query = request.getQueryString(); if ((query != null) && (query.indexOf("wsdl2") >= 0 || query.indexOf("wsdl") >= 0 || query.indexOf("xsd") >= 0 || query.indexOf("policy") >= 0)) { agent.processListService(request, response); } else { super.doGet(request, response); } }
protected org.apache.axis2.addressing.EndpointReference getWSATOEPR(WebServiceBinding binding) { org.apache.axis2.addressing.EndpointReference epr = getEPR(binding); if (epr == null) { epr = getPortLocationEPR(binding); } else if (epr.getAddress() == null || epr.getAddress().length() < 1) { org.apache.axis2.addressing.EndpointReference bindingEPR = getPortLocationEPR(binding); if (bindingEPR != null) { epr.setAddress(bindingEPR.getAddress()); } } return epr; }
private static void addSchemas(WSDLDefinition wsdlDef, AxisService axisService) { for (XSDefinition xsDef : wsdlDef.getXmlSchemas()) { if (xsDef.getSchema() != null) { axisService.addSchema(xsDef.getSchema()); updateSchemaRefs(xsDef.getSchema(), axisService.getName()); } } for (WSDLDefinition impDef : wsdlDef.getImportedDefinitions()) { addSchemas(impDef, axisService); } }
public ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference) { return new Axis2ReferenceBindingProvider(extensionPoints, endpointReference); }
@Override public void initDispatcher() { init(new HandlerDescription(NAME)); }
private static void changeLocations(Element element, String name) { NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { String tagName = nodeList.item(i).getLocalName(); if (IMPORT_TAG.equals(tagName) || INCLUDE_TAG.equals(tagName)) { processImport(nodeList.item(i), name); } } }
@Override public void configure() { // add in the response interceptor that turns the response message back into a SOAP // envelope before the response returns through the binding chain InvocationChain bindingChain = endpoint.getBindingInvocationChain(); // add transport interceptor bindingChain.addInterceptor(Phase.SERVICE_BINDING_POLICY, new Axis2ServiceBindingResponseInterceptor(endpoint) ); }
/** * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205 */ private static Definition getDefinition(Definition definition, QName serviceName) { if (serviceName == null) { return definition; } if (definition == null) { return null; } Object service = definition.getServices().get(serviceName); if (service != null) { return definition; } for (Object i : definition.getImports().values()) { List<Import> imports = (List<Import>)i; for (Import imp : imports) { Definition d = getDefinition(imp.getDefinition(), serviceName); if (d != null) { return d; } } } return null; }
public Axis2Config run() throws AxisFault, MalformedURLException { // collect together the classloaders that Axis2 requires in order to load // pluggable items such as the Tuscany MessageReceivers and the Xerces // document builder. ClassLoader wsBindingCL = getClass().getClassLoader(); ClassLoader axis2CL = URLBasedAxisConfigurator.class.getClassLoader(); ClassLoaderContext classLoaderContext = new ClassLoaderContext(wsBindingCL, axis2CL); classLoaderContext = new ClassLoaderContext(classLoaderContext.getClassLoader(), serviceDiscovery, XMLInputFactory.class, DocumentBuilderFactory.class); URL axis2xmlURL = wsBindingCL.getResource("org/apache/tuscany/sca/binding/ws/axis2/engine/conf/tuscany-axis2.xml"); if (axis2xmlURL != null) { URL repositoryURL = new URL(axis2xmlURL, "../repository/"); Axis2Config config = new Axis2Config(); config.classLoaderContext = classLoaderContext; config.axis2xmlURL = axis2xmlURL; config.repositoryURL = repositoryURL; return config; } else { return null; } } });
private static void updateSchemaRefs(XmlSchema parentSchema, String name) { for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { Object obj = iter.next(); if (obj instanceof XmlSchemaExternal) { XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; String location = extSchema.getSchemaLocation(); if (location.length() > 0 && location.indexOf(":/") < 0 && location.indexOf("?xsd=") < 0) { extSchema.setSchemaLocation(name + "?xsd=" + location); } if (extSchema.getSchema() != null) { updateSchemaRefs(extSchema.getSchema(), name); } } } }
private XmlSchema getSchema(XmlSchema parentSchema, String name) { for (Iterator iter = parentSchema.getIncludes().getIterator(); iter.hasNext();) { Object obj = iter.next(); if (obj instanceof XmlSchemaExternal) { XmlSchemaExternal extSchema = (XmlSchemaExternal)obj; if (extSchema.getSchemaLocation().endsWith(name)) { return extSchema.getSchema(); } else { XmlSchema schema = getSchema(extSchema.getSchema(), name); if (schema != null) { return schema; } } } } return null; }
public void configureBinding(Object context) { SecurityContext securityContext = ((Axis2BaseBindingProvider)context).getHttpSecurityContext(); for (Object policy : findPolicies()) { if (policy instanceof HTTPSPolicy) { HTTPSPolicy httpsPolicy = (HTTPSPolicy)policy; securityContext.setSSLEnabled(true); securityContext.setSSLProperties(httpsPolicy.toProperties()); // TODO - what is the right way to set trust/key store on client side? logger.info("HTTPSPolicyProvider: Setting JVM trust store to " + httpsPolicy.getTrustStore()); System.setProperty("javax.net.ssl.trustStore", httpsPolicy.getTrustStore()); System.setProperty("javax.net.ssl.trustStorePassword", httpsPolicy.getTrustStorePassword()); System.setProperty("javax.net.ssl.trustStoreType", httpsPolicy.getTrustStoreType()); logger.info("HTTPSPolicyProvider: Setting JVM key store to " + httpsPolicy.getKeyStore()); System.setProperty("javax.net.ssl.keyStore", httpsPolicy.getKeyStore()); System.setProperty("javax.net.ssl.keyStorePassword", httpsPolicy.getKeyStorePassword()); System.setProperty("javax.net.ssl.keyStoreType", httpsPolicy.getKeyStoreType()); return; } } } }
public void configureBinding(Object context) { ConfigurationContext configContext = ((Axis2BaseBindingProvider)context).getAxisConfigurationContext(); for ( Object policy : findPolicies() ) { if ( policy instanceof WSPolicy ) { WSPolicy wsPolicy = (WSPolicy)policy; try { configContext.getAxisConfiguration().applyPolicy(wsPolicy.getNeethiPolicy()); configContext.getAxisConfiguration().engageModule("rampart"); // TUSCANY-2824 // hack to make service side pick up rampart policies // "rampartPolicy" comes from RampartMessageData.KEY_RAMPART_POLICY // but I'm avoiding adding an explicit dependency just yet. // There must be a proper way of getting rampart to recognize // these policies configContext.setProperty("rampartPolicy", wsPolicy.getNeethiPolicy()); } catch ( AxisFault e ) { throw new RuntimeException(e); } } } } }