proxy.setPublishWSDLEndpoint(wsdlEndpoint.getAttributeValue()); } else if (wsdlKey != null) { proxy.setWSDLKey(wsdlKey.getAttributeValue());
/** * Tests building a proxy service with an unreachable endpoint specified as the published wsdl url with the * 'enablePublishWSDLSafeMode' set to true. * * @throws Exception if an error occurs when converting the URI string to a URI */ public void testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeDisabled() throws Exception { SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration axisCfg = new AxisConfiguration(); ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxyWithPublishWSDLSafeModeDisabled"); proxyService.setPublishWSDLEndpoint("wsdlEndPoint"); AddressEndpoint wsdlEndpoint = new AddressEndpoint(); EndpointDefinition endpointDefinition = new EndpointDefinition(); endpointDefinition.setAddress((new URI("http://invalid-host/SimpleStockService.wsdl")).toString()); wsdlEndpoint.setDefinition(endpointDefinition); proxyService.addParameter("enablePublishWSDLSafeMode", false); synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint); try { proxyService.buildAxisService(synCfg, axisCfg); Assert.fail("Axis service built with an unreachable wsdl endpoint should throw fault"); } catch (SynapseException e) { Assert.assertTrue("Unexpected exception thrown: " + e, e.getMessage().contains("Error reading from wsdl URI")); } }
/** * Tests building a proxy service with an unreachable endpoint specified as the published wsdl url with the * 'enablePublishWSDLSafeMode' set to false. * * @throws Exception if an error occurs when converting the URI string to a URI */ public void testBuildAxisServiceWithUnreachableWsdlEndpointWithPublishWSDLSafeModeEnabled() throws Exception { MessageContext synCtx = new TestMessageContext(); SynapseConfiguration synCfg = new SynapseConfiguration(); synCtx.setConfiguration(synCfg); AxisConfiguration axisCfg = new AxisConfiguration(); ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxyWithPublishWSDLSafeModeEnabled"); proxyService.setPublishWSDLEndpoint("wsdlEndPoint"); AddressEndpoint wsdlEndpoint = new AddressEndpoint(); EndpointDefinition endpointDefinition = new EndpointDefinition(); endpointDefinition.setAddress((new URI("http://invalid-host/SimpleStockService.wsdl")).toString()); wsdlEndpoint.setDefinition(endpointDefinition); proxyService.addParameter("enablePublishWSDLSafeMode", true); synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint); Assert.assertNull("Axis service built with an unreachable wsdl endpoint be null", proxyService.buildAxisService(synCfg, axisCfg)); }
/** * Tests building a proxy service with a faulty wsdl endpoint specified as the wsdl endpoint. * * @throws Exception if an error occurs when converting the URI string to a URI */ public void testBuildAxisServiceWithFaultyPublishWsdlEndpoint() throws Exception { SynapseConfiguration synCfg = new SynapseConfiguration(); AxisConfiguration axisCfg = new AxisConfiguration(); ProxyService proxyService = new ProxyService("faultyPublishWsdlEndpointProxy"); proxyService.setPublishWSDLEndpoint("wsdlEndPoint"); try { proxyService.buildAxisService(synCfg, axisCfg); Assert.fail("Axis service built with null wsdl endpoint should throw fault"); } catch (SynapseException e) { Assert.assertEquals("Unexpected exception thrown: " + e, "Unable to resolve WSDL url. wsdlEndPoint is null", e.getMessage()); } AddressEndpoint wsdlEndpoint = new AddressEndpoint(); EndpointDefinition endpointDefinition = new EndpointDefinition(); endpointDefinition.setAddress(getClass().getResource("SimpleStockService.wsdl").toURI().toString()); wsdlEndpoint.setDefinition(endpointDefinition); synCfg.addEndpoint("wsdlEndPoint", wsdlEndpoint); try { proxyService.buildAxisService(synCfg, axisCfg); Assert.fail("Axis service built with faulty wsdl endpoint should be null"); } catch (SynapseException e) { Assert.assertEquals("Unexpected exception thrown: " + e, "Error building service from WSDL", e.getMessage()); } }