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

The following examples show how to use org.apache.axis2.client.ServiceClient#sendReceive() . 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: ESBJAVA2262ContentEncodingGzipTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
@Test(groups = {
        "wso2.esb" }, description = "having 'Content-Encoding = gzip' within both in and out sequences and accepting gzip response")
public void gzipCompressionBothInAndOutSequencesTest() throws Exception {
    ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendAndReceiveGZIPCompressedPayload"));
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
    OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
    OperationContext operationContext = client.getLastOperationContext();
    MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
    CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext
            .getProperty(TRANSPORT_HEADERS);
    Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
    Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
    Assert.assertTrue(response.toString().contains("GZIP"));
    Assert.assertTrue(response.toString().contains("GZIP Company"));

}
 
Example 2
Source File: QueryTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
@Test
public void testFindDocuments_MultipleStatus() throws Exception {
	//Generate StoredQuery request message
	patientId = XdsTest.patientId;
	String message = findDocumentsQuery(patientId);
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getRegistryServiceClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 3
Source File: SOAPClient.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Sends a SOAP message with MTOM attachment and returns response as a OMElement.
 *
 * @param fileName   name of file to be sent as an attachment
 * @param targetEPR  service url
 * @param soapAction SOAP Action to set. Specify with "urn:"
 * @return OMElement response from BE service
 * @throws AxisFault in case of an invocation failure
 */
public OMElement sendSOAPMessageWithAttachment(String fileName, String targetEPR, String soapAction) throws AxisFault {
    OMFactory factory = OMAbstractFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://services.samples", "m0");
    OMElement payload = factory.createOMElement("uploadFileUsingMTOM", ns);
    OMElement request = factory.createOMElement("request", ns);
    OMElement image = factory.createOMElement("image", ns);

    FileDataSource fileDataSource = new FileDataSource(new File(fileName));
    DataHandler dataHandler = new DataHandler(fileDataSource);
    OMText textData = factory.createOMText(dataHandler, true);
    image.addChild(textData);
    request.addChild(image);
    payload.addChild(request);

    ServiceClient serviceClient = new ServiceClient();
    Options options = new Options();
    options.setTo(new EndpointReference(targetEPR));
    options.setAction(soapAction);
    options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
    options.setCallTransportCleanup(true);
    serviceClient.setOptions(options);
    return serviceClient.sendReceive(payload);
}
 
Example 4
Source File: CrossGatewayQueryTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Tis test initiate a GetDocuments Cross-Gateway Query (XGQ) to the XDS
 * Registry server's Initiating Gateway for documents discovered in
 * test 12306. Request LeafClass be returned.
 * @throws Exception
 */
@Test
public void testIGGetDocuments() throws Exception {
	//1. Submit a document first for a random patientId
	String patientId = generateAPatientId();
	String uuids = submitMultipleDocuments(patientId);
	
	//2. Generate StoredQuery request message
	String message = GetDocumentsQuery(uuids, false, homeProperty);
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getIGQueryServiceClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	
	//5. Verify that the 2 Documents found from the StoredQuery response. 
	NodeList count = getNodeCount(response, "ExtrinsicObject");
	assertTrue(count.getLength() == 2); 
	
	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 5
Source File: ESBJAVA2262ContentEncodingGzipTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = {"wso2.esb"}, description = "sending and accepting gzip compressed payload")
public void sendingAndReceivingGzipCompressedRequestInAllPathTest() throws Exception {
    ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendAndReceiveGZIPCompressedPayload"));
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, true);
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
    OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
    OperationContext operationContext = client.getLastOperationContext();
    MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
    CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
    Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
    Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
    Assert.assertTrue(response.toString().contains("GZIP"));
    Assert.assertTrue(response.toString().contains("GZIP Company"));
}
 
Example 6
Source File: ESBJAVA2262ContentEncodingGzipTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = {"wso2.esb"}, description = "having 'Accept-Encoding = gzip' within both in and out sequences")
public void sendingAndReceivingGzipCompressedPayloadTest() throws Exception {
    ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendingGZIPCompressedPayloadToClient"));
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, true);
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
    OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
    OperationContext operationContext = client.getLastOperationContext();
    MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
    CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
    Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
    Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
    Assert.assertTrue(response.toString().contains("GZIP"));
    Assert.assertTrue(response.toString().contains("GZIP Company"));
}
 
Example 7
Source File: ESBJAVA2262ContentEncodingGzipTestCase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
@Test(groups = {"wso2.esb"}, description = "having 'Content-Encoding = gzip' within both in and out sequences and accepting gzip response")
public void gzipCompressionBothInAndOutSequencesTest() throws Exception {
    ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendAndReceiveGZIPCompressedPayload"));
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
    OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
    OperationContext operationContext = client.getLastOperationContext();
    MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
    CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
    Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
    Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
    Assert.assertTrue(response.toString().contains("GZIP"));
    Assert.assertTrue(response.toString().contains("GZIP Company"));

}
 
Example 8
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testTransformationDocument() throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);

	//Then add a transformation doc
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_transformation.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be transformed
	message = message.replace("$tran_doc_uuid", doc_uuid);

	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a transformation document
	request = addOneDocument(request, document1, "doc1");

       System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 9
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testSubmitMultipleDocument() throws Exception {
	createPatient(patientId);

	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/submit_multiple_documents.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	String document2 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSDocumentEntry.uniqueId1", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	String uuid1 = getUUID();
	String uuid2 = getUUID();
	message = message.replace("$doc1", uuid1);
	message = message.replace("$doc2", uuid2);
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a referral summary document
	request = addOneDocument(request, document1, uuid1);
	//Add a Discharge summary documents
	request = addOneDocument(request, document1, uuid2);

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());
	
	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 10
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddDocument2Folder() throws Exception {
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/add_document2_folder.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	//replace document , submission set and folder uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$folder_uniqueid", "2.16.840.1.113883.3.65.3." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a referral summary document
	request = addOneDocument(request, document1, "doc1");
	
       System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 11
Source File: XdsTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * Submits new document and replaces the document
 * 
 * @param patientId
 * @return Document UUID
 * @throws Exception
 */

public String replaceDocument(String patientId) throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);

	//Then add a replacement doc
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_replacement.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be replaced.
	message = message.replace("$rplc_doc_uuid", doc_uuid);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a medical summary document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());
	
	String result = response.toString();
	System.out.println("Result:\n" +result);
	
	return doc_uuid;
}
 
Example 12
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testAddendumDocument() throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);
	
	//Then add an Addendum
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_addendum.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
	//replace document , submission set variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be appended.
	message = message.replace("$appendum_doc_uuid", doc_uuid);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a referral summary document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 13
Source File: CrossGatewayQueryTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
/**
 * This test initiate a FindDocuments Cross-Gateway Query (XGQ) to the XDS
 * 	Registry server's Responding Gateway for a pre-determined Patient ID.
 * 	Request ObjectRefs be returned.
 * @throws Exception
 */
@Test
public void testFindDocusMulObjectRefs() throws Exception {
	//1. Submit a document first for a random patientId
	String patientId = generateAPatientId();
	String uuids = submitMultipleDocuments(patientId);
	
	//2. Generate StoredQuery request message
	String message = findDocumentsQuery(patientId, "Approved", "ObjectRef");
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getRegistryGateWayClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	
	//5. Verify that the 2 Documents found from the StoredQuery response. 
	NodeList count = getNodeCount(response, "ObjectRef");
	assertTrue(count.getLength() == 2); 

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 14
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testReplaceDocument() throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);

	//Then add a replacement doc
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_replacement.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be replaced.
	message = message.replace("$rplc_doc_uuid", doc_uuid);
	
	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a medical summary document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());
	
	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 15
Source File: ProvideAndRegisterDocumentSetTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testTranformWithReplaceDocument() throws Exception {
	//First submit a document
	String doc_uuid = submitOneDocument(patientId);

	//Then add a transform with replace doc
	String message = IOUtils.toString( ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/document_trans_replace.xml"));
	String document1 = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/medical_summary.xml"));
	//replace document and submission set uniqueId variables with actual uniqueIds. 
	message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
	message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
	message = message.replace("$patientId", patientId);
	//populate the document uuid to be transformed and replaced
	message = message.replace("$tran_rplc_doc_uuid", doc_uuid);

	ServiceClient sender = getRepositoryServiceClient();			
	
	OMElement request = OMUtil.xmlStringToOM(message);			
	
	//Add a transformation document
	request = addOneDocument(request, document1, "doc1");

	System.out.println("Request:\n" +request);
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue());

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 16
Source File: WSXACMLEntitlementServiceClient.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Get decision in a secured manner using the
 * SAML implementation of XACML using X.509 credentials
 *
 * @return decision extracted from the SAMLResponse sent from PDP
 * @throws Exception
 */
@Override
public String getDecision(Attribute[] attributes, String appId) throws Exception {

    String xacmlRequest;
    String xacmlAuthzDecisionQuery;
    OMElement samlResponseElement;
    String samlResponse;
    String result;
    try {
        xacmlRequest = XACMLRequetBuilder.buildXACML3Request(attributes);
        xacmlAuthzDecisionQuery = buildSAMLXACMLAuthzDecisionQuery(xacmlRequest);
        ServiceClient sc = new ServiceClient();
        Options opts = new Options();
        opts.setTo(new EndpointReference(serverUrl + "ws-xacml"));
        opts.setAction("XACMLAuthzDecisionQuery");
        opts.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, authenticator);
        opts.setManageSession(true);
        sc.setOptions(opts);
        samlResponseElement = sc.sendReceive(AXIOMUtil.stringToOM(xacmlAuthzDecisionQuery));
        samlResponse = samlResponseElement.toString();
        result = extractXACMLResponse(samlResponse);
        sc.cleanupTransport();
        return result;
    } catch (Exception e) {
        log.error("Error occurred while getting decision using SAML.", e);
        throw new Exception("Error occurred while getting decision using SAML.", e);
    }
}
 
Example 17
Source File: RegistrytStoredQueryTest.java    From openxds with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSubmissionSets() throws Exception {
	//1. Submit a document first for a random patientId
	String patientId = generateAPatientId();
	String uuid = submitOneDocument(patientId);
	
	//2. Generate StoredQuery request message
	String message = GetSubmissionSetsQuery(uuid);
	OMElement request = OMUtil.xmlStringToOM(message);			
	System.out.println("Request:\n" +request);

	//3. Send a StoredQuery
	ServiceClient sender = getRegistryServiceClient();															 
	OMElement response = sender.sendReceive( request );
	assertNotNull(response); 

	//4. Verify the response is correct
	OMAttribute status = response.getAttribute(new QName("status"));
	assertEquals("urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success", status.getAttributeValue()); 
	
	//5. Verify that the given PatientId is found from the StoredQuery response. 
	NodeList nodes = getPatientIdNodes(response, patientId, "getSubmissionSets");
	assertTrue(nodes.getLength() == 1); 

	String result = response.toString();
	System.out.println("Result:\n" +result);
}
 
Example 18
Source File: ESBJAVA2262ContentEncodingGzipTestCase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Test(groups = { "wso2.esb" }, description = "having 'Content-Encoding = gzip' within outsequence")
public void gzipCompressionInsideOutSequenceTest() throws Exception {
    ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendingGZIPCompressedPayloadToClient"));
    client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
    OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
    OperationContext operationContext = client.getLastOperationContext();
    MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
    CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext
            .getProperty(TRANSPORT_HEADERS);
    Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
    Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
    Assert.assertTrue(response.toString().contains("GZIP"));
    Assert.assertTrue(response.toString().contains("GZIP Company"));

}
 
Example 19
Source File: SecurityWithServiceDescriptorTest.java    From product-ei with Apache License 2.0 4 votes vote down vote up
@Test(groups = { "wso2.bps",
	                 "wso2.bps.security" }, description = "BPEL security test scenario - secure BPEL process with service.xml file") public void securityWithServiceDescriptorTest()
			throws Exception {
		requestSender.waitForProcessDeployment(backEndUrl + "SWSDPService");
//		FrameworkConstants.start();

		String securityPolicyPath =
				FrameworkPathUtil.getSystemResourceLocation() + BPSTestConstants.DIR_ARTIFACTS +
				File.separator + BPSTestConstants.DIR_POLICY + File.separator + "utpolicy.xml";

		String endpointHttpS = "https://localhost:9645/services/SWSDPService";

		String trustStore =
				CarbonUtils.getCarbonHome() + File.separator + "repository" + File.separator +
				"resources" +
				File.separator + "security" + File.separator + "wso2carbon.jks";
		String clientKey = trustStore;
		OMElement result;

		System.setProperty("javax.net.ssl.trustStore", trustStore);
		System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon");

		if (log.isDebugEnabled()) {
			log.debug("Carbon Home: " + CarbonUtils.getCarbonHome());
		}
		ConfigurationContext ctx = ConfigurationContextFactory
				.createConfigurationContextFromFileSystem(
						CarbonUtils.getCarbonHome() + File.separator + "repository" +
						File.separator + "deployment" + File.separator + "client", null);
		ServiceClient sc = new ServiceClient(ctx, null);
		sc.engageModule("addressing");
		sc.engageModule("rampart");

		Options opts = new Options();

		opts.setTo(new EndpointReference(endpointHttpS));
		log.info(endpointHttpS);

		opts.setAction("urn:swsdp");

		log.info("SecurityPolicyPath " + securityPolicyPath);
		opts.setProperty(RampartMessageData.KEY_RAMPART_POLICY,
		                 loadPolicy(securityPolicyPath, clientKey, "admin"));
		sc.setOptions(opts);
		result = sc.sendReceive(
				AXIOMUtil.stringToOM("<p:swsdp xmlns:p=\"http://wso2.org/bpel/sample.wsdl\">\n" +
				                     "      <TestPart>ww</TestPart>\n" +
				                     "   </p:swsdp>"));
		log.info(result.getFirstElement().getText());
		Assert.assertFalse("Incorrect Test Result: " + result.toString(),
		                   !result.toString().contains("ww World"));
	}
 
Example 20
Source File: TestUtils.java    From micro-integrator with Apache License 2.0 3 votes vote down vote up
/**
 * Calls an operation of a target web service with the given parameters and
 * returns the result.
 * 
 * @param epr
 *            End point reference of the service
 * @param opName
 *            Operation to be called in the service
 * @param params
 *            Parameters of the service call
 * @return Service results
 * @throws AxisFault
 */
public static OMElement callOperation(String epr, String opName,
		Map<String, String> params) throws AxisFault {
	EndpointReference targetEPR = new EndpointReference(epr);
	OMElement payload = getPayload(opName, params);
	Options options = new Options();
	options.setTo(targetEPR);
	options.setAction("urn:" + opName);
	ServiceClient sender = new ServiceClient();
	sender.setOptions(options);
	OMElement result = sender.sendReceive(payload);
	return result;
}