private void configureCookie(ServiceClient client) throws AxisFault { if(SessionCookie != null){ Options option = client.getOptions(); option.setManageSession(true); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, SessionCookie); } }
public NfeConsulta2Stub(final org.apache.axis2.context.ConfigurationContext configurationContext, final java.lang.String targetEndpoint, final boolean useSeparateListener) throws org.apache.axis2.AxisFault { this.populateAxisService(); this.populateFaults(); this._serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext, this._service); this._serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference(targetEndpoint)); this._serviceClient.getOptions().setUseSeparateListener(useSeparateListener); this._serviceClient.getOptions().setSoapVersionURI(org.apache.axiom.soap.SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI); }
public void run() { client.getOptions().setAction(operation); try { long t1 = System.currentTimeMillis(); for (long i=0; i < iterations; i++) { OMElement response2 = client.sendReceive(msg); OMElement loadElement = response2.getFirstChildWithName(new QName("load")); System.out.println(invokerName + ": " + loadElement.toString()); } long t2 = System.currentTimeMillis(); System.out.println("================================================================"); System.out.println(invokerName + " completed requests."); System.out.println("================================================================"); runningTime = t2 - t1; } catch (AxisFault axisFault) { System.out.println(axisFault.getMessage()); } } }
public static void clearSecurityProperties(Options options) { Options current = options; while (current != null && current.getProperty(SynapseConstants.RAMPART_POLICY) != null) { current.setProperty(SynapseConstants.RAMPART_POLICY, null); current = current.getParent(); } }
public static Options getOptions(String soapAction, long timeout, EndpointReference destination) { Options opts = new Options(); opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); opts.setAction(soapAction); opts.setTimeOutInMilliSeconds(timeout); opts.setMessageId(UUIDGenerator.getUUID()); opts.setTo(destination); return opts; }
public NFeDistDFeInteresseResponse nfeDistDFeInteresse(final NFeDistDFeInteresse nfeDistDFeInteresse) throws java.rmi.RemoteException { org.apache.axis2.context.MessageContext _messageContext = null; try { final org.apache.axis2.client.OperationClient _operationClient = this._serviceClient.createClient(this._operations[0].getName()); _operationClient.getOptions().setAction("http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe/nfeDistDFeInteresse"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); this.addPropertyToOperationClient(_operationClient, org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR, "&"); _messageContext = new org.apache.axis2.context.MessageContext(); env = this.toEnvelope(Stub.getFactory(_operationClient.getOptions().getSoapVersionURI()), nfeDistDFeInteresse, this.optimizeContent(new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe", "nfeDistDFeInteresse"))); this._serviceClient.addHeadersToEnvelope(env); _messageContext.setEnvelope(env); final java.lang.String exceptionClassName = (java.lang.String) this.faultExceptionClassNameMap.get(faultElt.getQName()); final java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); final java.lang.Exception ex = (java.lang.Exception) exceptionClass.newInstance(); final java.lang.String messageClassName = (java.lang.String) this.faultMessageMap.get(faultElt.getQName()); final java.lang.Class messageClass = java.lang.Class.forName(messageClassName); final java.lang.Object messageObject = this.fromOM(faultElt, messageClass, null);
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("urn:deleteEmployee"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); _messageContext = new org.apache.axis2.context.MessageContext(); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), deleteEmployee9, optimizeContent(new javax.xml.namespace.QName("http://ws.wso2.org/dataservice/samples/batch_request_sample", "deleteEmployee")),new javax.xml.namespace.QName("http://ws.wso2.org/dataservice/samples/batch_request_sample", "deleteEmployee")); _serviceClient.addHeadersToEnvelope(env); _messageContext.setEnvelope(env); if (_messageContext.getTransportOut() != null) { _messageContext.getTransportOut().getSender().cleanup(_messageContext);
org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); _operationClient.getOptions().setAction("urn:applySecurity"); _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), applySecurity18, optimizeContent(new javax.xml.namespace.QName("http://service.config.security.carbon.wso2.org", "applySecurity")), new javax.xml.namespace.QName("http://service.config.security.carbon.wso2.org", "applySecurity")); _serviceClient.addHeadersToEnvelope(env); _messageContext.setEnvelope(env); if ( _operations[0].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); _operations[0].setMessageReceiver( _callbackReceiver);
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); }
public void performInstallation(String actionType) throws Exception { try { ServiceClient client = provAdminStub._getServiceClient(); client.engageModule("addressing"); // IMPORTANT Options options = client.getOptions(); options.setUseSeparateListener(true); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); provAdminStub.startperformProvisioningAction(actionType, callback); handleCallback(); } catch (AxisFault e) { if (e.getFaultCode() != null) { handleException(bundle.getString(e.getFaultCode().getLocalPart()), e); } else { handleException(bundle.getString("failed.perform.prov.action"), e); } } }
serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); EndpointReference targetEPR = new EndpointReference("http://myservice"); options.setTo(targetEPR); QName methodName = new QName("ns","methodName"); Class<?>[] returnTypes = new Class[] { String.class }; Object[] args = new Object[] { "parameter" }; Object[] response = serviceClient.invokeBlocking(methodName, args, returnTypes);
public void setInvokerName(String invokerName) { this.invokerName = invokerName; if (statefull) { client.getOptions().setManageSession(true); client.getOptions().setAction("setClientName"); OMElement cName = fac.createOMElement("cName", null); cName.setText(invokerName); try { OMElement response = client.sendReceive(cName); System.out.println(response.getText()); } catch (AxisFault axisFault) { axisFault.printStackTrace(); } } }
private MessageContext getNewMessageContextUsingAxis2Info(CreateSequenceMessage createSequenceMessage) throws AxisFault, RMMessageBuildingException { MessageContext messageContext = new MessageContext(); messageContext.setServiceContext(this.axis2Info.getServiceContext()); messageContext.setEnvelope(createSequenceMessage.toSOAPEnvelope()); messageContext.setMessageID(UUIDGenerator.getUUID()); messageContext.setTransportIn(this.axis2Info.getTransportIn()); messageContext.setTransportOut(this.axis2Info.getTransportOut()); messageContext.setReplyTo(this.ackToEpr); messageContext.setProperty(MercuryConstants.PROCESS_RM_CONTROL_MESSAGE, Constants.VALUE_TRUE); messageContext.setOptions(new Options()); // set the correct options messageContext.getOptions().setTo(this.axis2Info.getOptions().getTo()); messageContext.getOptions().setUseSeparateListener(this.axis2Info.getOptions().isUseSeparateListener()); messageContext.setServerSide(this.axis2Info.isServerSide()); return messageContext; }
private void initStub(String cookie) throws AxisFault { String serviceURL = AuthAdminServiceClient.SERVICE_URL + "RestApiAdmin"; stub = new RestApiAdminStub(null, serviceURL); ServiceClient client = stub._getServiceClient(); Options options = client.getOptions(); options.setTimeOutInMilliSeconds(15 * 60 * 1000); options.setProperty(HTTPConstants.SO_TIMEOUT, 15 * 60 * 1000); options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, 15 * 60 * 1000); options.setManageSession(true); options.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, cookie); }
public static Stub authenticateStub(Stub stub, String sessionCookie, String backendURL) { // Three minutes long soTimeout = 5 * 60 * 1000; ServiceClient client = stub._getServiceClient(); Options option = client.getOptions(); option.setManageSession(true); option.setTimeOutInMilliSeconds(soTimeout); option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, sessionCookie); option.setTo(new EndpointReference( backendURL + client.getServiceContext().getAxisService().getName().replaceAll("[^a-zA-Z]", ""))); return stub; }
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; }
private void sendWorkListNotification(Message event, String endpoint, String username, byte[] password, String url) throws RemoteException, UnsupportedEncodingException, RegistryException { try { WorkListServiceStub stub = new WorkListServiceStub(configContext, url + "WorkListService"); ServiceClient client = stub._getServiceClient(); CarbonUtils.setBasicAccessSecurityHeaders(username, new String(password, "UTF-8"), client); client.getOptions().setManageSession(true); stub.addTask(endpoint.substring(7),event.getMessage().getFirstElement().getText(), 5); } catch (Exception ex) { if (url.startsWith("local") && ex.getMessage().equals("The input stream for an incoming message is null.")) { //ignore exception from the local transport since empty response } else { throw new RegistryException(ex.getMessage(), ex); } } }
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); }
protected WsrfResourceStub(EndpointReference resourceEpr, long timeout) { this.resourceEndpointReference = resourceEpr; logger.info("resourceEprInWsrfResourceStub Constructor" + resourceEpr.toString()); timeoutInMilliSeconds = timeout; opts = new Options(); opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE); opts.setTo(resourceEpr); opts.setTimeOutInMilliSeconds(timeout); }
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); }