ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("repository", null); NetWS_0Stub stub = new NetWS_0Stub(ctx, aEndPoint); ServiceClient client = stub._getServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(aEndPoint)); //Added chunking property: options.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); client.setOptions(options); //Engaged rampart module: client.engageModule("rampart"); return stub;
// Create an instance of org.apache.axis2.client.ServiceClient ServiceClient client = ... // Create an instance of org.apache.axis2.client.Options Options options = new Options(); List list = new ArrayList(); // Create an instance of org.apache.commons.httpclient.Header Header header = new Header(); // Http header. Name : user, Value : admin header.setName("user"); header.setValue("admin"); list.add(header); options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, list); client.setOptions(options);
@Override public void activateObject(final PooledObject<ServiceClient> pooledServiceClient) throws Exception { final ServiceClient serviceClient = pooledServiceClient.getObject(); // to avoid overriding settings that could impact other calls to this service client // we extend the option and will restore them after final Options originalOptions = serviceClient.getOptions(); final Options options = new Options(originalOptions); options.setProperty(ORIGINAL_OPTIONS_TO_RESTORE_ON_RETURN, originalOptions); // HttpClient is cached (in ServiceClientPoolObjectFactory.createOptions()) so we need to // add our own HttpState so that the one from HttpClient is not reused!! options.setProperty(HTTPConstants.CACHED_HTTP_STATE, new HttpState()); serviceClient.setOptions(options); }
Stub s = new Stub(); ServiceClient sc = s.getServiceClient(); Options o = sc.getOptions(); o.setTimeOutInMilliSeconds(2000); //2 seconds sc.setOptions(o); s.setServiceClient(sc);
public static void main(String[] ars) throws AxisFault, XMLStreamException { // Client side keystore location, here we use same keystore System.setProperty("javax.net.ssl.trustStore", "../httpsService/target/jetty-ssl.keystore"); System.setProperty("javax.net.ssl.trustStorePassword", "axis2key"); String epr = "https://localhost:8443/services/SimpleService/"; Options options = new Options(); options.setTo(new EndpointReference(epr)); ServiceClient sender = new ServiceClient(); sender.setOptions(options); OMElement ret = sender.sendReceive(creatMsg()); ret.serialize(System.out); }
public void sendRequestOneWay(String payloadStr, EndpointReference targetEPR) throws XMLStreamException, AxisFault { OMElement payload = AXIOMUtil.stringToOM(payloadStr); Options options = new Options(); options.setTo(targetEPR); ServiceClient sender = new ServiceClient(); sender.setOptions(options); log.info("Request: " + payload.toString()); sender.fireAndForget(payload); }
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("clientrepo", null); ServiceClient sc = new ServiceClient(ctx, null); sc.engageModule("rampart"); // create option object Options opts = new Options(); // setting target EPR opts.setTo(new EndpointReference(serviceUrl); opts.setAction("urn:something"); try { opts.setProperty(RampartMessageData.KEY_RAMPART_POLICY, loadPolicy("policy.xml")); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } sc.setOptions(opts); OMElement res = sc.sendReceive(payload);
public static OMElement sendRequest(String payloadStr, EndpointReference targetEPR) throws XMLStreamException, AxisFault { OMElement payload = AXIOMUtil.stringToOM(payloadStr); Options options = new Options(); options.setTo(targetEPR); ServiceClient sender = new ServiceClient(); sender.setOptions(options); log.info("Request: " + payload.toString()); OMElement result = sender.sendReceive(payload); log.info("Response: " + result.toString()); return result; }
protected void sendNotification(OMElement topicHeader, OMElement payload, String endpoint) throws AxisFault { // The parameter args is used as a mechanism to pass any argument into this method, which // is used by the implementations that extend the behavior of the default Carbon Event // Dispatcher. ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(endpoint)); options.setAction(EventingConstants.WSE_PUBLISH); serviceClient.setOptions(options); serviceClient.addHeader(topicHeader); serviceClient.fireAndForget(payload); } }
protected void sendNotification(OMElement topicHeader, OMElement payload, String endpoint) throws AxisFault { // The parameter args is used as a mechanism to pass any argument into this method, which // is used by the implementations that extend the behavior of the default Carbon Event // Dispatcher. ServiceClient serviceClient = new ServiceClient(); Options options = new Options(); options.setTo(new EndpointReference(endpoint)); options.setAction(EventingConstants.WSE_PUBLISH); serviceClient.setOptions(options); serviceClient.addHeader(topicHeader); serviceClient.fireAndForget(payload); } }
private ServiceClient getServiceClient(QName rstQn, String issuerAddress) throws AxisFault { AxisService axisService = new AxisService("SecurityTokenService" + UUIDGenerator.getUUID()); axisService.setClientSide(true); AxisOperation operation = new OutInAxisOperation(rstQn); axisService.addOperation(operation); ServiceClient client = new ServiceClient(this.configCtx, axisService); if (this.options != null) { client.setOptions(options); } //Set the action client.getOptions().setAction(action); client.getOptions().setTo(new EndpointReference(issuerAddress)); client.engageModule("rampart"); return client; }
@Setup @SuppressWarnings("unused") private void setUp(AxisTestClientContext context, Channel channel, AxisTestClientConfigurator[] configurators) throws Exception { this.configurators = configurators; sender = context.getSender(); serviceClient = new ServiceClient(context.getConfigurationContext(), null); axisOptions = new Options(); axisOptions.setTo(channel.getEndpointReference()); serviceClient.setOptions(axisOptions); }
@Setup @SuppressWarnings("unused") private void setUp(AxisTestClientContext context, Channel channel, AxisTestClientConfigurator[] configurators) throws Exception { this.configurators = configurators; sender = context.getSender(); serviceClient = new ServiceClient(context.getConfigurationContext(), null); axisOptions = new Options(); axisOptions.setTo(channel.getEndpointReference()); serviceClient.setOptions(axisOptions); }
@Setup @SuppressWarnings("unused") private void setUp(AxisTestClientContext context, Channel channel, AxisTestClientConfigurator[] configurators) throws Exception { this.configurators = configurators; sender = context.getSender(); serviceClient = new ServiceClient(context.getConfigurationContext(), null); axisOptions = new Options(); axisOptions.setTo(channel.getEndpointReference()); serviceClient.setOptions(axisOptions); }
private ServiceClient createServiceClient(OMElement message) throws AxisFault { String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName(); Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef); ServiceClient client = new ServiceClient(); CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client); client.setOptions(opts); return client; }
private ServiceClient configureServiceClientForSubscription(OMElement message) throws AxisFault { String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName(); Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef); ServiceClient client = new ServiceClient(); client.setOptions(opts); CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client); return client; }
private ServiceClient createServiceClient(OMElement message) throws AxisFault { String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName(); Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef); ServiceClient client = new ServiceClient(); CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client); client.setOptions(opts); return client; }
private ServiceClient configureServiceClientForSubscription(OMElement message) throws AxisFault { String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName(); Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef); ServiceClient client = new ServiceClient(); client.setOptions(opts); CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client); return client; }
public static void main(String[] args) throws AxisFault { String axis2_xml = CLIENT_REPO_PATH + File.separator + "client_axis2.xml"; ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml); Options clientOptions = new Options (); clientOptions.setTo(new EndpointReference (toEPR)); ServiceClient serviceClient = new ServiceClient (configContext,null); clientOptions.setAction("urn:wsrm:Ping"); serviceClient.setOptions(clientOptions); serviceClient.fireAndForget(getPingOMBlock("ping1")); serviceClient.fireAndForget(getPingOMBlock("ping2")); clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true"); serviceClient.fireAndForget(getPingOMBlock("ping3")); serviceClient.cleanup(); }
public boolean unSubscribe(String subscriptionId) throws MsgBrokerClientException { OMFactory factory = OMAbstractFactory.getOMFactory(); OMElement message = WSEProtocolClient.createUnsubscribeMsg(); OMElement identifierEl = factory.createOMElement("Identifier", message.getNamespace()); identifierEl.setText(subscriptionId); String soapAction = message.getNamespace().getNamespaceURI() + "/" + message.getLocalName(); Options opts = CommonRoutines.getOptions(soapAction, getTimeoutInMilliSeconds(), brokerEndpointRef); try { ServiceClient client = new ServiceClient(); client.setOptions(opts); CommonRoutines.setHeaders(soapAction, brokerEndpointRef.getAddress(), client, identifierEl); client.sendReceive(message); client.cleanupTransport(); } catch (AxisFault e) { throw new MsgBrokerClientException("unable to send subscribe msg", e); } return true; }