org.apache.axis2.description.WSDL2Constants Java Examples

The following examples show how to use org.apache.axis2.description.WSDL2Constants. 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: XdsTest.java    From openxds with Apache License 2.0 6 votes vote down vote up
protected Options getOptions(String action, boolean enableMTOM, String url) {
		Options options = new Options();
		options.setAction(action);		
	    options.setProperty(WSDL2Constants.ATTRIBUTE_MUST_UNDERSTAND,"1");
	    options.setTo( new EndpointReference(url) );
		options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
//		try {
//			String from = InetAddress.getLocalHost().getHostAddress();	
//			options.setFrom(new EndpointReference(from));
//		}catch(UnknownHostException e) {
//			//ignore From
//		}
		if (enableMTOM)
			options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);
		else
			options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_FALSE);
		//use SOAP12, 
		options.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
		return options;
	}
 
Example #3
Source File: IntegratorStatefulHandler.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Finds axis Service and the Operation for DSS requests
 *
 * @param msgContext request message context
 * @throws AxisFault if any exception occurs while finding axis service or operation
 */
private static void dispatchAndVerify(MessageContext msgContext) throws AxisFault {
    requestDispatcher.invoke(msgContext);
    AxisService axisService = msgContext.getAxisService();
    if (axisService != null) {
        httpLocationBasedDispatcher.invoke(msgContext);
        if (msgContext.getAxisOperation() == null) {
            requestURIOperationDispatcher.invoke(msgContext);
        }

        AxisOperation axisOperation;
        if ((axisOperation = msgContext.getAxisOperation()) != null) {
            AxisEndpoint axisEndpoint =
                    (AxisEndpoint) msgContext.getProperty(WSDL2Constants.ENDPOINT_LOCAL_NAME);
            if (axisEndpoint != null) {
                AxisBindingOperation axisBindingOperation = (AxisBindingOperation) axisEndpoint
                        .getBinding().getChild(axisOperation.getName());
                msgContext.setProperty(Constants.AXIS_BINDING_OPERATION, axisBindingOperation);
            }
            msgContext.setAxisOperation(axisOperation);
        }
    }
}
 
Example #4
Source File: Util.java    From carbon-commons with Apache License 2.0 5 votes vote down vote up
/**
 * Get the WS-D types of an Axis2 service. By default the port types of the
 * service are considered as WS-D types.
 *
 * @param axisService The Axis2 service
 * @return a WS-D type to be associated with the service
 */
public static QName getTypes(AxisService axisService) {
    QName portType;
    String localPart;
    if (axisService.getParameter(WSDL2Constants.INTERFACE_LOCAL_NAME) != null) {
        localPart = (String) axisService.getParameter(
                WSDL2Constants.INTERFACE_LOCAL_NAME).getValue();
    } else {
        localPart = axisService.getName() + Java2WSDLConstants.PORT_TYPE_SUFFIX;
    }
    portType = new QName(axisService.getTargetNamespace(), localPart);
    return portType;
}
 
Example #5
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 #6
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 #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 '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 #8
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 #9
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 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 #10
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AxisBinding and populates it with default SOAP 1.2 properties
 */
private AxisBinding createDefaultSOAP12Binding(String name, String interfaceName) {
	AxisBinding soap12Binding = new AxisBinding();
	soap12Binding.setName(new QName(name + Java2WSDLConstants.SOAP12BINDING_NAME_SUFFIX));
	soap12Binding.setType(WSDL2Constants.URI_WSDL2_SOAP);
	soap12Binding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL, WSDL2Constants.HTTP_PROTOCAL);
	soap12Binding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
	soap12Binding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);
	soap12Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
       soap12Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
	return soap12Binding;
}
 
Example #11
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AxisBinding and populates it with default HTTP properties
 */
private AxisBinding createDefaultHTTPBinding(String name, String interfaceName) {
	AxisBinding httpBinding = new AxisBinding();
	httpBinding.setName(new QName(name + Java2WSDLConstants.HTTP_BINDING));
	httpBinding.setType(WSDL2Constants.URI_WSDL2_HTTP);
	httpBinding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);
	httpBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
       httpBinding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
	return httpBinding;
}
 
Example #12
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a AxisBinding and populates it with default SOAP 1.1 properties
 */
private AxisBinding createDefaultSOAP11Binding(String name, String interfaceName) {
	AxisBinding soap11Binding = new AxisBinding();
	soap11Binding.setName(new QName(name + Java2WSDLConstants.BINDING_NAME_SUFFIX));
	soap11Binding.setType(WSDL2Constants.URI_WSDL2_SOAP);
	soap11Binding.setProperty(WSDL2Constants.ATTR_WSOAP_PROTOCOL, WSDL2Constants.HTTP_PROTOCAL);
	soap11Binding.setProperty(WSDL2Constants.ATTR_WSOAP_VERSION, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
	soap11Binding.setProperty(WSDL2Constants.INTERFACE_LOCAL_NAME, interfaceName);
	soap11Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
       soap11Binding.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
	return soap11Binding;
}
 
Example #13
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisBindingOperation and populates it with SOAP 1.1 properties
 */
private AxisBindingOperation createDefaultSOAP11BindingOperation(
		AxisOperation axisOp, String httpLocation, String inputAction,
		AxisBinding soap11Binding) {
	AxisBindingOperation soap11BindingOperation = new AxisBindingOperation();
	soap11BindingOperation.setAxisOperation(axisOp);
	soap11BindingOperation.setName(axisOp.getName());
	soap11BindingOperation.setParent(soap11Binding);
	soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION,
			httpLocation);
	soap11Binding.addChild(soap11BindingOperation.getName(), soap11BindingOperation);
	soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, inputAction);
	return soap11BindingOperation;
}
 
Example #14
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisBindingOperation and populates it with SOAP 1.2 properties
 */
private AxisBindingOperation createDefaultSOAP12BindingOperation(
		AxisOperation axisOp, String httpLocation, String inputAction,
		AxisBinding soap12Binding) {
	AxisBindingOperation soap12BindingOperation = new AxisBindingOperation();
	soap12BindingOperation.setAxisOperation(axisOp);
	soap12BindingOperation.setName(axisOp.getName());
	soap12BindingOperation.setParent(soap12Binding);
	soap12BindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION,
			httpLocation);
	soap12Binding.addChild(soap12BindingOperation.getName(), soap12BindingOperation);
	soap12BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION, inputAction);
	return soap12BindingOperation;
}
 
Example #15
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Creates AxisBindingOperation and populates it with HTTP properties
 */
private AxisBindingOperation createDefaultHTTPBindingOperation(
		AxisOperation axisOp, String httpLocation, String httpMethod,
		AxisBinding httpBinding) {
	AxisBindingOperation httpBindingOperation = new AxisBindingOperation();
	httpBindingOperation.setAxisOperation(axisOp);
	httpBindingOperation.setName(axisOp.getName());
	httpBindingOperation.setParent(httpBinding);
	httpBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION, httpLocation);
	httpBindingOperation.setProperty(WSDL2Constants.ATTR_WHTTP_METHOD, httpMethod);
	httpBinding.addChild(httpBindingOperation.getName(), httpBindingOperation);
	return httpBindingOperation;
}
 
Example #16
Source File: ESBJAVA2262ContentEncodingGzipTestCase.java    From micro-integrator 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 #17
Source File: ESBJAVA2262ContentEncodingGzipTestCase.java    From micro-integrator 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 #18
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a set of default endpoints for this service
 */
private void createDefaultEndpoints(AxisService axisService, AxisBinding soap11Binding,
		AxisBinding soap12Binding, AxisBinding httpBinding) {
	Map<String, TransportInDescription> transportsIn = axisConfig.getTransportsIn();
	Iterator<TransportInDescription> iterator = transportsIn.values().iterator();
	while (iterator.hasNext()) {
		/*
		 * Used to indicate whether a HTTPEndpoint is needed. Http endpoint
		 * is needed only for http and https transports
		 */
		boolean needHttp = false;

		/* The prefix is used to generate endpoint names */
		String prefix = "";
		TransportInDescription transportIn = iterator.next();
		String transportInName = transportIn.getName();
		if (HTTP_TRANSPORT.equalsIgnoreCase(transportInName)) {
			needHttp = true;
		} else if (HTTPS_TRANSPORT.equalsIgnoreCase(transportInName)) {
			needHttp = true;
			prefix = WSDL2Constants.DEFAULT_HTTPS_PREFIX;
		} else if (transportInName != null) {
			prefix = transportInName.toUpperCase();
		}

		/* Creates a default SOAP 1.1 endpoint */
		AxisEndpoint soap11Endpoint = new AxisEndpoint();
		String soap11EndpointName = prefix
				+ WSDL2Constants.DEFAULT_SOAP11_ENDPOINT_NAME;
		soap11Endpoint.setName(soap11EndpointName);
		soap11Endpoint.setBinding(soap11Binding);
		soap11Endpoint.setParent(axisService);
		soap11Endpoint.setTransportInDescription(transportInName);
		soap11Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
           soap11Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
		axisService.addEndpoint(soap11EndpointName, soap11Endpoint);

           /* setting soap11 endpoint as the default endpoint */
		axisService.setEndpointName(soap11EndpointName);

		/* Creates a default SOAP 1.2 endpoint */
		AxisEndpoint soap12Endpoint = new AxisEndpoint();
		String soap12EndpointName = prefix
				+ WSDL2Constants.DEFAULT_SOAP12_ENDPOINT_NAME;
		soap12Endpoint.setName(soap12EndpointName);
		soap12Endpoint.setBinding(soap12Binding);
		soap12Endpoint.setParent(axisService);
		soap12Endpoint.setTransportInDescription(transportInName);
		soap12Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
           soap12Endpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
		axisService.addEndpoint(soap12EndpointName, soap12Endpoint);

		/* Creates a HTTP endpoint if its http or https transport is used */
		if (needHttp) {
			AxisEndpoint httpEndpoint = new AxisEndpoint();
			String httpEndpointName = prefix
					+ WSDL2Constants.DEFAULT_HTTP_ENDPOINT_NAME;
			httpEndpoint.setName(httpEndpointName);
			httpEndpoint.setBinding(httpBinding);
			httpEndpoint.setParent(axisService);
			httpEndpoint.setTransportInDescription(transportInName);
			httpEndpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE, httpLocationTable);
               httpEndpoint.setProperty(WSDL2Constants.HTTP_LOCATION_TABLE_FOR_RESOURCE, httpLocationTableForResource);
			axisService.addEndpoint(httpEndpointName, httpEndpoint);
		}
	}
}
 
Example #19
Source File: DBDeployer.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Utility method for creating AxisOperation objects.
 */
private AxisOperation createAxisOperation(String operationName, String httpLocation,
		String method, boolean hasResult,
		AxisBinding soap11Binding, AxisBinding soap12Binding, AxisBinding httpBinding,
		String description) {
	AxisOperation axisOperation;
	if (hasResult) {
		axisOperation = new InOutAxisOperation(new QName(operationName));
		DBInOutMessageReceiver inoutMsgReceiver = new DBInOutMessageReceiver();
		axisOperation.setMessageReceiver(inoutMsgReceiver);
		axisOperation.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
	} else {
		axisOperation = new InOnlyAxisOperation(new QName(operationName));
		DBInOnlyMessageReceiver inonlyMsgReceiver = new DBInOnlyMessageReceiver();
		axisOperation.setMessageReceiver(inonlyMsgReceiver);
		axisOperation.setMessageExchangePattern(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY);
	}

	axisOperation.setStyle(WSDLConstants.STYLE_DOC);

	String opName = axisOperation.getName().getLocalPart();
	// Create a default SOAP 1.1 Binding operation
	AxisBindingOperation soap11BindingOperation = createDefaultSOAP11BindingOperation(
			axisOperation, httpLocation, "urn:" + opName, soap11Binding);

	// Create a default SOAP 1.2 Binding operation
	AxisBindingOperation soap12BindingOperation = createDefaultSOAP12BindingOperation(
			axisOperation, httpLocation, "urn:" + opName, soap12Binding);

	// Create a default HTTP Binding operation
	AxisBindingOperation httpBindingOperation = createDefaultHTTPBindingOperation(
			axisOperation, httpLocation, method, httpBinding);

       if(httpLocation.startsWith("/")){
           httpLocation = httpLocation.substring(1);
       }

       Pattern httpLocationPattern = WSDLUtil.getConstantFromHTTPLocationForResource(httpLocation, method);
       this.httpLocationTableForResource.put(httpLocationPattern, axisOperation);

	// Create the in and out axis messages for this operation
	AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
	if (inMessage != null) {
		inMessage.setName(operationName + Java2WSDLConstants.MESSAGE_SUFFIX);
		createAxisBindingMessage(soap11BindingOperation, inMessage,
                   WSDLConstants.MESSAGE_LABEL_IN_VALUE, false);
		createAxisBindingMessage(soap12BindingOperation, inMessage,
                   WSDLConstants.MESSAGE_LABEL_IN_VALUE, false);
		createAxisBindingMessage(httpBindingOperation, inMessage,
                   WSDLConstants.MESSAGE_LABEL_IN_VALUE, false);
	}

	if (axisOperation instanceof InOutAxisOperation) {
		AxisMessage outMessage =
                   axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
		if (outMessage != null) {
			outMessage.setName(operationName + Java2WSDLConstants.RESPONSE_MESSAGE);
			createAxisBindingMessage(soap11BindingOperation, outMessage,
                       WSDLConstants.MESSAGE_LABEL_OUT_VALUE, false);
			createAxisBindingMessage(soap12BindingOperation, outMessage,
                       WSDLConstants.MESSAGE_LABEL_OUT_VALUE, false);
			createAxisBindingMessage(httpBindingOperation, outMessage,
                       WSDLConstants.MESSAGE_LABEL_OUT_VALUE, false);
		}
	}
	/* Set the fault message, only if operation returns a result*/
	if (hasResult) {
		AxisMessage faultMessage = new AxisMessage();
		faultMessage.setName(DBConstants.DS_FAULT_ELEMENT);
		faultMessage.setElementQName(new QName(DBConstants.WSO2_DS_NAMESPACE,
                DBConstants.DS_FAULT_ELEMENT));
		axisOperation.setFaultMessages(faultMessage);
		createAxisBindingMessage(soap11BindingOperation, faultMessage,
                WSDLConstants.MESSAGE_LABEL_FAULT_VALUE, true);
		createAxisBindingMessage(soap12BindingOperation, faultMessage,
                WSDLConstants.MESSAGE_LABEL_FAULT_VALUE, true);
		createAxisBindingMessage(httpBindingOperation, faultMessage,
                WSDLConstants.MESSAGE_LABEL_FAULT_VALUE, true);
	}

	axisOperation.setDocumentation(description);
	return axisOperation;
}
 
Example #20
Source File: InOnlyMEPHandler.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
@Override
// Handle IN_ONLY operations
public void flowComplete(MessageContext msgContext) {
    if (msgContext.getEnvelope() == null) {
        return;
    }
    AxisService axisService = msgContext.getAxisService();
    if (axisService == null ||
        SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
        axisService.isClientSide()) {
        return;
    }

    try {
        // Process Request Counter
        OperationContext opContext = msgContext.getOperationContext();
        if (opContext != null && opContext.isComplete()) {
            AxisOperation axisOp = opContext.getAxisOperation();
            if (axisOp != null && axisOp.isControlOperation()) {
                return;
            }
            if (axisOp != null) {
                String mep = axisOp.getMessageExchangePattern();
                if (mep != null &&
                    (mep.equals(WSDL2Constants.MEP_URI_IN_ONLY) ||
                     mep.equals(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY))) {

                    // Increment operation counter
                    final AxisOperation axisOperation = msgContext.getAxisOperation();
                    if (axisOperation != null) {
                        Parameter operationParameter =
                                axisOperation.getParameter(StatisticsConstants.IN_OPERATION_COUNTER);
                        if (operationParameter != null) {
                            ((AtomicInteger) operationParameter.getValue()).incrementAndGet();
                        } else {
                            log.error(StatisticsConstants.IN_OPERATION_COUNTER +
                                      " has not been set for operation " +
                                      axisService.getName() + "." + axisOperation.getName());
                            return;
                        }

                        // Calculate response times
                        try {
                            ResponseTimeCalculator.calculateResponseTimes(msgContext);
                        } catch (AxisFault axisFault) {
                            log.error("Cannot compute response times", axisFault);
                        }
                    }

                    // Increment global counter
                    Parameter globalRequestCounter =
                            msgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER);
                    ((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet();

                    updateCurrentInvocationGlobalStatistics(msgContext);
                }
            }
        }
    } catch (Throwable e) {  // Catching Throwable since exceptions here should not be propagated up
        log.error("Could not call InOnlyMEPHandler.flowComplete", e);
    }
}
 
Example #21
Source File: InOutMEPHandler.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public InvocationResponse invoke(MessageContext outMsgContext) throws AxisFault {
    if(outMsgContext.getEnvelope() == null){
        return InvocationResponse.CONTINUE;
    }
    if (outMsgContext.getFLOW() != MessageContext.OUT_FLOW &&
        outMsgContext.getFLOW() != MessageContext.OUT_FAULT_FLOW) {
        log.error("InOutMEPHandler not deployed in OUT/OUT_FAULT flow. Flow: " +
                  outMsgContext.getFLOW());
        return InvocationResponse.CONTINUE;
    }
    try {
        AxisService axisService = outMsgContext.getAxisService();
        if(axisService == null) {
           updateStatistics(outMsgContext);
           return InvocationResponse.CONTINUE;
       } else if (SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
           axisService.isClientSide()) {
           return InvocationResponse.CONTINUE;
       }

        final AxisOperation axisOperation = outMsgContext.getAxisOperation();
        if(axisOperation != null && axisOperation.isControlOperation()){
            return InvocationResponse.CONTINUE;
        }
        if (axisOperation != null) {
            String mep = axisOperation.getMessageExchangePattern();
            if (mep != null &&
                (mep.equals(WSDL2Constants.MEP_URI_OUT_IN) ||
                    mep.equals(WSDL2Constants.MEP_URI_OUT_ONLY) ||
                    mep.equals(WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN))) { // If this ConfigurationContext is used for sending messages out, do not change the stats
                return InvocationResponse.CONTINUE;
            }
            // Process operation request count
            Parameter inOpCounter =
                axisOperation.getParameter(StatisticsConstants.IN_OPERATION_COUNTER);
            if (inOpCounter != null) {
                ((AtomicInteger) inOpCounter.getValue()).incrementAndGet();
            } else {
                log.error(StatisticsConstants.IN_OPERATION_COUNTER +
                          " has not been set for operation " +
                          axisService.getName() + "." + axisOperation.getName());
                return InvocationResponse.CONTINUE;
            }

            // Process operation response count
            Parameter outOpCounter =
                axisOperation.getParameter(StatisticsConstants.OUT_OPERATION_COUNTER);
            if (outOpCounter != null) {
                ((AtomicInteger) outOpCounter.getValue()).incrementAndGet();
            } else {
                log.error(StatisticsConstants.OUT_OPERATION_COUNTER +
                          " has not been set for operation " +
                          axisService.getName() + "." + axisOperation.getName());
                return InvocationResponse.CONTINUE;
            }
        }
        updateStatistics(outMsgContext);
    } catch (Throwable e) {
        log.error("Could not call InOutMEPHandler.invoke", e);
     }
    return InvocationResponse.CONTINUE;
}