Java Code Examples for org.apache.axis2.client.ServiceClient#addHeader()

The following examples show how to use org.apache.axis2.client.ServiceClient#addHeader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorkflowDeployerClient.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public WorkflowDeployerClient(String bpsURL, String username) throws AxisFault {

        bpelUploaderStub = new BPELUploaderStub(bpsURL + BPEL_UPLOADER_SERVICE);
        ServiceClient serviceClient = bpelUploaderStub._getServiceClient();
        OMElement mutualSSLHeader;
        try {
            String headerString = WFImplConstant.MUTUAL_SSL_HEADER.replaceAll("\\$username", username);
            mutualSSLHeader = AXIOMUtil.stringToOM(headerString);
            serviceClient.addHeader(mutualSSLHeader);
        } catch (XMLStreamException e) {
            throw new AxisFault("Error while creating mutualSSLHeader XML Element.", e);
        }
        Options options = serviceClient.getOptions();
        serviceClient.setOptions(options);

        humanTaskUploaderStub = new HumanTaskUploaderStub(bpsURL + HT_UPLOADER_SERVICE);
        ServiceClient htServiceClient = humanTaskUploaderStub._getServiceClient();
        Options htOptions = htServiceClient.getOptions();
        htServiceClient.setOptions(htOptions);
        htServiceClient.addHeader(mutualSSLHeader);
    }
 
Example 2
Source File: WSEventDispatcher.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
protected synchronized void sendNotification(OMElement topicHeader,
                                OMElement tenantDomainHeader,
                                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.
    ConfigurationContextService configurationContextService =
            WSEventBrokerHolder.getInstance().getConfigurationContextService();

    ServiceClient serviceClient =
            new ServiceClient(configurationContextService.getClientConfigContext(), null);

    Options options = new Options();
    options.setTo(new EndpointReference(endpoint));
    options.setAction(EventingConstants.WSE_PUBLISH);
    serviceClient.setOptions(options);
    serviceClient.addHeader(topicHeader);

    if (tenantDomainHeader != null){
        serviceClient.addHeader(tenantDomainHeader);
    }

    serviceClient.fireAndForget(payload);
}
 
Example 3
Source File: WSEventDispatcher.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 4
Source File: EventBrokerAdminClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void publish(String topic, OMElement element) throws AxisFault {
    log.debug("published element to " + topic);
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext,
                                                                backendUrl + "/publish/" + topic);
    configureCookie(service._getServiceClient());
    ServiceClient serviceClient = service._getServiceClient();

    OMElement header = omFactory.createOMElement(new QName(TOPIC_HEADER_NS, TOPIC_HEADER_NAME));
    header.setText(topic);
    serviceClient.addHeader(header);
    serviceClient.getOptions().setTo(new EndpointReference(backendUrl + "/publish"));
    //serviceClient.getOptions().setTo(new EndpointReference(brokerUrl));
    serviceClient.getOptions().setAction("urn:publish");
    serviceClient.sendRobust(element);
}
 
Example 5
Source File: EventBrokerAdminClient.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void unsubscribe(String subscriptionID) throws RemoteException {
    log.debug("Unsubscribed to " + subscriptionID);
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, backendUrl);
    configureCookie(service._getServiceClient());
    ServiceClient serviceClient = service._getServiceClient();
    OMElement header = omFactory.createOMElement(new QName(WSE_EVENTING_NS, WSE_EN_IDENTIFIER));
    header.setText(subscriptionID);
    serviceClient.addHeader(header);
    service.unsubscribe(new OMElement[] {});
}
 
Example 6
Source File: EventBrokerAdminClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public void publish(String topic, OMElement element) throws AxisFault {
    log.debug("published element to "+ topic );
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, backendUrl
            +"/publish/"+topic);
    configureCookie(service._getServiceClient());
    ServiceClient serviceClient = service._getServiceClient();

    OMElement header = omFactory.createOMElement(new QName(TOPIC_HEADER_NS, TOPIC_HEADER_NAME));
    header.setText(topic);
    serviceClient.addHeader(header);
    serviceClient.getOptions().setTo(new EndpointReference(backendUrl+"/publish"));
    //serviceClient.getOptions().setTo(new EndpointReference(brokerUrl));
    serviceClient.getOptions().setAction("urn:publish");
    serviceClient.sendRobust(element);
}
 
Example 7
Source File: EventBrokerAdminClient.java    From product-ei with Apache License 2.0 5 votes vote down vote up
public void unsubscribe(String subscriptionID) throws RemoteException {
    log.debug("Unsubscribed to "+ subscriptionID);
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, backendUrl);
    configureCookie(service._getServiceClient());
    ServiceClient serviceClient = service._getServiceClient();
    OMElement header = omFactory.createOMElement(new QName(WSE_EVENTING_NS, WSE_EN_IDENTIFIER));
    header.setText(subscriptionID);
    serviceClient.addHeader(header);
    service.unsubscribe(new OMElement[]{});
}
 
Example 8
Source File: BPELPackageManagementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public BPELPackageManagementServiceClient(String bpsURL, String username) throws AxisFault {

        stub = new BPELPackageManagementServiceStub(bpsURL + WFImplConstant.BPS_PACKAGE_SERVICES_URL);
        ServiceClient serviceClient = stub._getServiceClient();
        OMElement mutualSSLHeader;
        try {
            String headerString = WFImplConstant.MUTUAL_SSL_HEADER.replaceAll("\\$username", username);
            mutualSSLHeader = AXIOMUtil.stringToOM(headerString);
            serviceClient.addHeader(mutualSSLHeader);
        } catch (XMLStreamException e) {
            throw new AxisFault("Error while creating mutualSSLHeader XML Element.", e);
        }
        Options options = serviceClient.getOptions();
        serviceClient.setOptions(options);
    }
 
Example 9
Source File: HumanTaskClientAPIAdminClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public HumanTaskClientAPIAdminClient(String bpsURL, String username) throws AxisFault {

        stub = new HumanTaskClientAPIAdminStub(bpsURL + WFImplConstant.HT_SERVICES_URL);
        ServiceClient serviceClient = stub._getServiceClient();
        OMElement mutualSSLHeader;
        try {
            String headerString = WFImplConstant.MUTUAL_SSL_HEADER.replaceAll("\\$username", username);
            mutualSSLHeader = AXIOMUtil.stringToOM(headerString);
            serviceClient.addHeader(mutualSSLHeader);
        } catch (XMLStreamException e) {
            throw new AxisFault("Error while creating mutualSSLHeader XML Element.", e);
        }
        Options options = serviceClient.getOptions();
        serviceClient.setOptions(options);
    }
 
Example 10
Source File: ProcessManagementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public ProcessManagementServiceClient(String bpsURL, String username) throws AxisFault {

        stub = new ProcessManagementServiceStub(bpsURL + WFImplConstant.BPS_PROCESS_SERVICES_URL);
        ServiceClient serviceClient = stub._getServiceClient();
        OMElement mutualSSLHeader;
        try {
            String headerString = WFImplConstant.MUTUAL_SSL_HEADER.replaceAll("\\$username", username);
            mutualSSLHeader = AXIOMUtil.stringToOM(headerString);
            serviceClient.addHeader(mutualSSLHeader);
        } catch (XMLStreamException e) {
            throw new AxisFault("Error while creating mutualSSLHeader XML Element.", e);
        }
        Options options = serviceClient.getOptions();
        serviceClient.setOptions(options);
    }
 
Example 11
Source File: BrokerClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void publish(String topic, OMElement element) throws AxisFault{
    log.debug("published element to "+ topic );
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, brokerUrl+"/publish/"+topic);
    configureCookie(service._getServiceClient());
    ServiceClient serviceClient = service._getServiceClient();

    OMElement header = fac.createOMElement(new QName(TOPIC_HEADER_NS, TOPIC_HEADER_NAME));
    header.setText(topic);
    serviceClient.addHeader(header);
    serviceClient.getOptions().setTo(new EndpointReference(brokerUrl+"/publish"));
    //serviceClient.getOptions().setTo(new EndpointReference(brokerUrl));
    serviceClient.getOptions().setAction("urn:publish");
    serviceClient.sendRobust(element);
}
 
Example 12
Source File: BrokerClient.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
public void unsubscribe(String subscriptionID) throws RemoteException{
    log.debug("Unsubscribed to "+ subscriptionID);
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, brokerUrl);
    configureCookie(service._getServiceClient());
    ServiceClient serviceClient = service._getServiceClient();
    OMElement header = fac.createOMElement(new QName(WSE_EVENTING_NS, WSE_EN_IDENTIFIER));
    header.setText(subscriptionID);
    serviceClient.addHeader(header);
    service.unsubscribe(new OMElement[]{});
}
 
Example 13
Source File: BrokerClient.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public void renewSubscription(String subscriptionID, long time) throws RemoteException{
    log.debug("Renewed subscription "+ subscriptionID + " " + time);
    EventBrokerServiceStub service = new EventBrokerServiceStub(configurationContext, brokerUrl);
    
    configureCookie(service._getServiceClient());
    
    ServiceClient serviceClient = service._getServiceClient();
    OMElement header = fac.createOMElement(new QName(WSE_EVENTING_NS, WSE_EN_IDENTIFIER));
    header.setText(subscriptionID);
    serviceClient.addHeader(header);
    
    Calendar calendar = new GregorianCalendar();
    calendar.setTimeInMillis(time);
    
    ExpirationType expirationType = new ExpirationType();
    expirationType.setObject(calendar);

          
    RenewResponse renewOp = service.renewOp(expirationType, null);
    //TODO I think there is nothing to do with renewOp response
    
    
}