Refine search
@Override public Object call() throws Exception { Service service = Service.create( url, new QName( NAMESPACE_URI, serviceName ) ); T port = service.getPort( clazz ); // add TRUST_USER if necessary if ( StringUtils.isNotBlank( System.getProperty( "pentaho.repository.client.attemptTrust" ) ) ) { ( (BindingProvider) port ).getRequestContext().put( MessageContext.HTTP_REQUEST_HEADERS, Collections.singletonMap( TRUST_USER, Collections.singletonList( username ) ) ); } else { // http basic authentication ( (BindingProvider) port ).getRequestContext().put( BindingProvider.USERNAME_PROPERTY, username ); ( (BindingProvider) port ).getRequestContext().put( BindingProvider.PASSWORD_PROPERTY, password ); } // accept cookies to maintain session on server ( (BindingProvider) port ).getRequestContext().put( BindingProvider.SESSION_MAINTAIN_PROPERTY, true ); // support streaming binary data // TODO mlowery this is not portable between JAX-WS implementations (uses com.sun) ( (BindingProvider) port ).getRequestContext().put( JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192 ); SOAPBinding binding = (SOAPBinding) ( (BindingProvider) port ).getBinding(); binding.setMTOMEnabled( true ); return port; } } );
String username = getUsername(); if (username != null) { stubProperties.put(BindingProvider.USERNAME_PROPERTY, username); stubProperties.put(BindingProvider.PASSWORD_PROPERTY, password); stubProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); "] is not a customizable JAX-WS stub: it does not implement interface [javax.xml.ws.BindingProvider]"); ((BindingProvider) stub).getRequestContext().putAll(stubProperties);
@Test public void testWithManualMultiplexEprCreation() throws Exception { Service numService = Service.create(NumberFactoryImpl.NUMBER_SERVICE_QNAME); Number num = numService.getPort(Number.class); InvocationHandler handler = Proxy.getInvocationHandler(num); BindingProvider bp = (BindingProvider)handler; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NUMBER_SERVANT_ADDRESS_ROOT + "103"); IsEvenResponse numResp = num.isEven(); assertTrue("103 is not even", Boolean.FALSE.equals(numResp.isEven())); }
@Override public void newToken(String token) { if (useSoapHeaderSessions) { for (PublicInterface p : getServiceInterfaces().values()) { List<Header> headers = new ArrayList<Header>(); try { Token tokenObject = new Token(token); Header sessionHeader = new Header(new QName("uri:org.bimserver.shared", "token"), tokenObject, new JAXBDataBinding(Token.class)); headers.add(sessionHeader); } catch (JAXBException e) { LOGGER.error("", e); } ((BindingProvider) p).getRequestContext().put(Header.HEADER_LIST, headers); } } }
@Test public void testUnmatchedActions() throws Exception { AddNumberImpl port = getPort(); BindingProvider bp = (BindingProvider)port; java.util.Map<String, Object> requestContext = bp.getRequestContext(); requestContext.put(BindingProvider.SOAPACTION_URI_PROPERTY, "http://cxf.apache.org/input4"); try { //CXF-2035 port.addNumbers3(-1, -1); } catch (Exception e) { assertTrue(e.getMessage().contains("Unexpected wrapper")); } }
String username = getUsername(); if (username != null) { stubProperties.put(BindingProvider.USERNAME_PROPERTY, username); stubProperties.put(BindingProvider.PASSWORD_PROPERTY, password); stubProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); "] is not a customizable JAX-WS stub: it does not implement interface [javax.xml.ws.BindingProvider]"); ((BindingProvider) stub).getRequestContext().putAll(stubProperties);
public void connect(TokenHolder tokenHolder) { for (Class<? extends PublicInterface> interface1 : interfaces) { JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean(); cpfb.setServiceClass(interface1); cpfb.setAddress(address + "/" + interface1.getSimpleName()); Map<String, Object> properties = new HashMap<String, Object>(); properties.put("mtom-enabled", Boolean.TRUE); cpfb.setProperties(properties); PublicInterface serviceInterface = (PublicInterface) cpfb.create(); client = ClientProxy.getClient(serviceInterface); HTTPConduit http = (HTTPConduit) client.getConduit(); http.getClient().setConnectionTimeout(360000); http.getClient().setAllowChunking(false); http.getClient().setReceiveTimeout(320000); if (!useSoapHeaderSessions) { ((BindingProvider) serviceInterface).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); } add(interface1.getName(), serviceInterface); } tokenHolder.registerTokenChangeListener(this); notifyOfConnect(); }
@Test public void testInvocationWithSpringBeanAnnotation() throws Exception { GreeterService service = new GreeterService(); assertNotNull(service); Greeter greeter = service.getGreeterPort(); BindingProvider bp = (BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/SpringBean"); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true); String result = greeter.greetMe("World"); assertEquals("Hello World", result); assertEquals("Bonjour World", greeter.sayHi()); }
/** * used for non UDDI AuthToken authentication. I.e. HTTP NTLM, HTTP BASIC, HTTP DIGEST * @param bindingProvider * @param publisherId * @param password */ public static void setCredentials(BindingProvider bindingProvider, String publisherId, String password) { bindingProvider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, publisherId); bindingProvider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); }
@Test public void testInvocationWithSpringBeanAnnotation() throws Exception { GreeterService service = new GreeterService(); assertNotNull(service); Greeter greeter = service.getGreeterPort(); BindingProvider bp = (BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/SpringBean"); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true); String result = greeter.greetMe("World"); assertEquals("Hello World", result); assertEquals("Bonjour World", greeter.sayHi()); }
/** * used for non UDDI AuthToken authentication. I.e. HTTP NTLM, HTTP BASIC, HTTP DIGEST * @param bindingProvider * @param publisherId * @param password */ public static void setCredentials(BindingProvider bindingProvider, String publisherId, String password) { bindingProvider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, publisherId); bindingProvider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); }
@Test public void testExtraSubClassWithJaxbFromEndpoint() throws Throwable { Widget expected = new ExtendedWidget(42, "blah", "blah", true, true); TestService testClient = getTestClient(); ((BindingProvider)testClient).getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/service/TestEndpoint"); Widget widgetFromService = testClient.getWidgetById(42); Assert.assertEquals(expected, widgetFromService); }
/** * Sets the endpoint URL. * @param url the url to set */ void setEndpointUrl(String url) { ((BindingProvider) pronomService).getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); }
@Test public void testConnection() throws Exception { QName serviceName = new QName("http://cxf.apache.org/systest/jaxws/", "HelloService"); HelloService service = new HelloService(null, serviceName); assertNotNull(service); Hello hello = service.getHelloPort(); ((BindingProvider)hello).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/hello"); assertEquals("getSayHi", hello.sayHi("SayHi")); }
/** * Sets the endpoint address of the given SOAP client. * * @param soapClient the SOAP client to set the endpoint address for * @param endpointAddress the target endpoint address */ @Override public void setEndpointAddress(BindingProvider soapClient, String endpointAddress) { soapClient.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); }
@Test public void testInvocationWithPerRequestAnnotation() throws Exception { GreeterService service = new GreeterService(); assertNotNull(service); Greeter greeter = service.getGreeterPort(); BindingProvider bp = (BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/PerRequest"); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true); String result = greeter.greetMe("World"); assertEquals("Hello World", result); assertEquals("Bonjour default", greeter.sayHi()); } @Test
private void setEndpointForBindingProvider(Object port, String endpoint) { Map<String, Object> requestContext = ((BindingProvider) port) .getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint); }
@Test public void testInvocationWithPerRequestAnnotation() throws Exception { GreeterService service = new GreeterService(); assertNotNull(service); Greeter greeter = service.getGreeterPort(); BindingProvider bp = (BindingProvider)greeter; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/PerRequest"); bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true); String result = greeter.greetMe("World"); assertEquals("Hello World", result); assertEquals("Bonjour default", greeter.sayHi()); } @Test
/** * Sets the endpoint address of the given SOAP client. * * @param soapClient the SOAP client to set the endpoint address for * @param endpointAddress the target endpoint address */ @Override public void setEndpointAddress(BindingProvider soapClient, String endpointAddress) { soapClient.getRequestContext().put( BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress); }
@Test public void testGetPortOneParam() throws Exception { URL url = getClass().getResource("/wsdl/hello_world.wsdl"); Service service = Service.create(url, serviceName); Greeter greeter = service.getPort(Greeter.class); String response = new String("Bonjour"); try { ((BindingProvider)greeter).getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://localhost:" + PORT + "/SoapContext/SoapPort"); greeter.greetMe("test"); String reply = greeter.sayHi(); assertNotNull("no response received from service", reply); assertEquals(response, reply); } catch (UndeclaredThrowableException ex) { throw (Exception)ex.getCause(); } }