javax.wsdl.extensions.soap.SOAPOperation Java Examples

The following examples show how to use javax.wsdl.extensions.soap.SOAPOperation. 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: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private String getSoapActionForOperation( String operationName )
	throws IOException {
	String soapAction = null;
	Port port = getWSDLPort();
	if( port != null ) {
		BindingOperation bindingOperation = port.getBinding().getBindingOperation( operationName, null, null );
		for( ExtensibilityElement element : (List< ExtensibilityElement >) bindingOperation
			.getExtensibilityElements() ) {
			if( element instanceof SOAPOperation ) {
				soapAction = ((SOAPOperation) element).getSoapActionURI();
			}
		}
	}
	if( soapAction == null ) {
		soapAction = getStringParameter( "namespace" ) + "/" + operationName;
	}
	return soapAction;
}
 
Example #2
Source File: WsdlUtils.java    From hop with Apache License 2.0 5 votes vote down vote up
/**
 * Get the Soap Action URI from the operation's soap:operation extensiblity element.
 *
 * @param operation A WSDL Operation.
 * @return Soap action URI as string, null if not defined.
 */
protected static String getSOAPAction( BindingOperation operation ) {
  ExtensibilityElement e = findExtensibilityElement( (ElementExtensible) operation, SOAP_OPERATION_ELEMENT_NAME );
  if ( e != null ) {
    if ( e instanceof SOAP12Operation ) {
      return ( (SOAP12Operation) e ).getSoapActionURI();
    } else {
      return ( (SOAPOperation) e ).getSoapActionURI();
    }
  }
  return null;
}
 
Example #3
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPOperation getSoapOperation(List<ExtensibilityElement> exts) {
    if (exts != null) {
        for (ExtensibilityElement ext : exts) {
            if (isSOAPOperation(ext)) {
                return getSoapOperation(ext);
            }
        }
    }
    return null;
}
 
Example #4
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static SOAPOperation createSoapOperation(ExtensionRegistry extReg, boolean isSOAP12)
    throws WSDLException {
    ExtensibilityElement extElement = null;
    if (isSOAP12) {
        extElement = extReg.createExtension(BindingOperation.class,
                                                             new QName(WSDLConstants.NS_SOAP12,
                                                                       "operation"));
    } else {
        extElement = extReg.createExtension(BindingOperation.class,
                                                           new QName(WSDLConstants.NS_SOAP11,
                                                                     "operation"));
    }
    return getSoapOperation(extElement);
}
 
Example #5
Source File: WsdlUtils.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
/**
 * Get the Soap Action URI from the operation's soap:operation extensiblity element.
 *
 * @param operation
 *          A WSDL Operation.
 * @return Soap action URI as string, null if not defined.
 */
protected static String getSOAPAction( BindingOperation operation ) {
  ExtensibilityElement e = findExtensibilityElement( operation, SOAP_OPERATION_ELEMENT_NAME );
  if ( e != null ) {
    if ( e instanceof SOAP12Operation ) {
      return ( (SOAP12Operation) e ).getSoapActionURI();
    } else {
      return ( (SOAPOperation) e ).getSoapActionURI();
    }
  }
  return null;
}
 
Example #6
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void addOperationSOAPBinding( Definition localDef, Operation wsdlOp, Binding bind ) {
	try {
		// creating operation binding
		BindingOperation bindOp = localDef.createBindingOperation();
		bindOp.setName( wsdlOp.getName() );

		// adding soap extensibility elements
		SOAPOperation soapOperation = (SOAPOperation) extensionRegistry.createExtension( BindingOperation.class,
			new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "operation" ) );
		soapOperation.setStyle( "document" );
		// NOTA-BENE: Come settare SOAPACTION? jolie usa SOAP1.1 o 1.2? COme usa la SoapAction?
		soapOperation.setSoapActionURI( wsdlOp.getName() );
		bindOp.addExtensibilityElement( soapOperation );
		bindOp.setOperation( wsdlOp );

		// adding input
		BindingInput bindingInput = localDef.createBindingInput();
		SOAPBody body = (SOAPBody) extensionRegistry.createExtension( BindingInput.class,
			new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "body" ) );
		body.setUse( "literal" );
		bindingInput.addExtensibilityElement( body );
		bindOp.setBindingInput( bindingInput );

		// adding output
		BindingOutput bindingOutput = localDef.createBindingOutput();
		bindingOutput.addExtensibilityElement( body );
		bindOp.setBindingOutput( bindingOutput );

		// adding fault
		if( !wsdlOp.getFaults().isEmpty() ) {
			for( Object o : wsdlOp.getFaults().entrySet() ) {
				BindingFault bindingFault = localDef.createBindingFault();
				SOAPFault soapFault = (SOAPFault) extensionRegistry.createExtension( BindingFault.class,
					new QName( NameSpacesEnum.SOAP.getNameSpaceURI(), "fault" ) );
				soapFault.setUse( "literal" );
				String faultName = ((Entry) o).getKey().toString();
				bindingFault.setName( faultName );
				soapFault.setName( faultName );
				bindingFault.addExtensibilityElement( soapFault );
				bindOp.addBindingFault( bindingFault );
			}
		}

		bind.addBindingOperation( bindOp );

	} catch( WSDLException ex ) {
		ex.printStackTrace();
	}

}
 
Example #7
Source File: ComponentBuilder.java    From tesb-studio-se with Apache License 2.0 4 votes vote down vote up
private static ServiceInfo populateComponent(Service service) {
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setServiceName(service.getQName());
    Collection<Port> ports = service.getPorts().values();
    for (Port port : ports) {
        String soapLocation = null;
        SOAPAddress soapAddress = findExtensibilityElement(port.getExtensibilityElements(), SOAPAddress.class);
        if (null != soapAddress) {
            soapLocation = soapAddress.getLocationURI();
        } else {
            SOAP12Address soap12Address = findExtensibilityElement(port.getExtensibilityElements(), SOAP12Address.class);
            if (null != soap12Address) {
                soapLocation = soap12Address.getLocationURI();
            }
        }
        Binding binding = port.getBinding();
        for (BindingOperation operation : (Collection<BindingOperation>) binding.getBindingOperations()) {
            SOAPOperation soapOperation = findExtensibilityElement(operation.getExtensibilityElements(), SOAPOperation.class);

            if (null != soapOperation && OPERATION_TYPE_RPC.equalsIgnoreCase(soapOperation.getStyle())) {
                // TESB-6151 disable display of unsupported RPC type.
                serviceInfo.setHasRpcOperation(true);
                continue;
            }
            OperationInfo operationInfo = new OperationInfo(operation.getOperation());
            operationInfo.setPortName(port.getName());
            operationInfo.setNamespaceURI(binding.getPortType().getQName().getNamespaceURI());
            if (soapOperation != null) {
                operationInfo.setSoapActionURI(soapOperation.getSoapActionURI());
            } else {
                SOAP12Operation soap12Operation = findExtensibilityElement(operation.getExtensibilityElements(),
                        SOAP12Operation.class);
                if (soap12Operation != null) {
                    operationInfo.setSoapActionURI(soap12Operation.getSoapActionURI());
                }
            }

            operationInfo.setTargetURL(soapLocation);
            serviceInfo.addOperation(operationInfo);
        }
    }
    return serviceInfo;
}
 
Example #8
Source File: WsdlScenarioGenerator.java    From citrus-simulator with Apache License 2.0 4 votes vote down vote up
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    Assert.notNull(wsdlResource,
            "Missing either WSDL location system property setting or explicit WSDL resource for scenario auto generation");

    Definition wsdl = getWsdlDefinition(wsdlResource);
    XmlObject wsdlObject = compileWsdl(wsdlResource);
    SchemaTypeSystem schemaTypeSystem = compileXsd(wsdlObject);

    for (Object item : wsdl.getBindings().values()) {
        Binding binding = (Binding) item;

        for (Object operationItem : binding.getBindingOperations()) {
            BindingOperation operation = (BindingOperation) operationItem;

            SchemaType requestElem = getSchemaType(schemaTypeSystem, operation.getName(), operation.getOperation().getInput().getName());
            SchemaType responseElem = getSchemaType(schemaTypeSystem, operation.getName(), operation.getOperation().getOutput().getName());

            String soapAction = "";
            List extensions = operation.getExtensibilityElements();
            if (extensions != null) {
                for (int i = 0; i < extensions.size(); i++) {
                    ExtensibilityElement extElement = (ExtensibilityElement) extensions.get(i);
                    if (extElement instanceof SOAPOperation) {
                        SOAPOperation soapOp = (SOAPOperation) extElement;
                        soapAction = soapOp.getSoapActionURI();
                    }
                }
            }

            String scenarioName;
            switch (namingStrategy) {
                case INPUT:
                    scenarioName = operation.getOperation().getInput().getName();
                    break;
                case OPERATION:
                    scenarioName = operation.getOperation().getName();
                    break;
                case SOAP_ACTION:
                    scenarioName = soapAction;
                    break;
                default:
                    throw new SimulatorException("Unknown scenario naming strategy");
            }

            if (beanFactory instanceof BeanDefinitionRegistry) {
                log.info("Register auto generated scenario as bean definition: " + scenarioName);
                BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(WsdlOperationScenario.class)
                        .addConstructorArgValue(operation)
                        .addPropertyValue("soapAction", soapAction)
                        .addPropertyValue("input", generateRequest(operation, SampleXmlUtil.createSampleForType(requestElem)))
                        .addPropertyValue("output", generateResponse(operation, SampleXmlUtil.createSampleForType(responseElem)));

                if (beanFactory.containsBeanDefinition("inboundXmlDataDictionary")) {
                    beanDefinitionBuilder.addPropertyReference("inboundDataDictionary", "inboundXmlDataDictionary");
                }

                if (beanFactory.containsBeanDefinition("outboundXmlDataDictionary")) {
                    beanDefinitionBuilder.addPropertyReference("outboundDataDictionary", "outboundXmlDataDictionary");
                }

                ((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(scenarioName, beanDefinitionBuilder.getBeanDefinition());
            } else {
                log.info("Register auto generated scenario as singleton: " + scenarioName);
                WsdlOperationScenario scenario = createScenario(operation, soapAction, generateRequest(operation, SampleXmlUtil.createSampleForType(requestElem)), generateResponse(operation, SampleXmlUtil.createSampleForType(responseElem)));
                beanFactory.registerSingleton(scenarioName, scenario);
            }
        }
    }
}
 
Example #9
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static boolean isSOAPOperation(Object obj) {
    return obj instanceof SOAPOperation || obj instanceof SOAP12Operation;
}
 
Example #10
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static SOAPOperation getSoapOperation(Object obj) {
    if (isSOAPOperation(obj)) {
        return getProxy(SOAPOperation.class, obj);
    }
    return null;
}
 
Example #11
Source File: SOAPBindingUtil.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static boolean isSOAPOperation(Object obj) {
    return obj instanceof SOAPOperation || obj instanceof SOAP12Operation;
}
 
Example #12
Source File: PartialWSDLProcessor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private static void setSoapOperationExtElement(BindingOperation bo, ExtensionRegistry extReg) throws Exception {
    SOAPOperation soapOperation = SOAPBindingUtil.createSoapOperation(extReg, false);
    soapOperation.setStyle(style);
    soapOperation.setSoapActionURI("");
    bo.addExtensibilityElement(soapOperation);
}
 
Example #13
Source File: HeavyweightOperationInfoBuilder.java    From tomee with Apache License 2.0 4 votes vote down vote up
public HeavyweightOperationInfoBuilder(BindingOperation bindingOperation, ServiceEndpointMethodMapping methodMapping, JavaWsdlMapping mapping, XmlSchemaInfo schemaInfo) throws OpenEJBException {
    Operation operation = bindingOperation.getOperation();
    this.operationName = operation.getName();
    this.operationStyle = JaxRpcOperationInfo.OperationStyle.valueOf(operation.getStyle().toString());
    this.outputMessage = operation.getOutput() == null ? null : operation.getOutput().getMessage();
    this.inputMessage = operation.getInput().getMessage();

    // faults
    for (Object o : operation.getFaults().values()) {
        faults.add((Fault) o);
    }

    this.mapping = mapping;
    this.methodMapping = methodMapping;
    this.schemaInfo = schemaInfo;

    // index types - used to process build exception class constructor args
    for (JavaXmlTypeMapping javaXmlTypeMapping : mapping.getJavaXmlTypeMapping()) {
        String javaClassName = javaXmlTypeMapping.getJavaType();
        if (javaXmlTypeMapping.getAnonymousTypeQname() != null) {
            String anonymousTypeQName = javaXmlTypeMapping.getAnonymousTypeQname();
            anonymousTypes.put(anonymousTypeQName, javaClassName);
        } else if (javaXmlTypeMapping.getRootTypeQname() != null) {
            QName qname = javaXmlTypeMapping.getRootTypeQname();
            publicTypes.put(qname, javaClassName);
        }
    }

    // BindingStyle
    if (methodMapping.getWrappedElement() != null) {
        bindingStyle = BindingStyle.DOCUMENT_LITERAL_WRAPPED;
    } else {
        BindingInput bindingInput = bindingOperation.getBindingInput();

        SOAPOperation soapOperation = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPOperation.class, bindingOperation.getExtensibilityElements());
        String styleString = soapOperation.getStyle();
        if (styleString == null) {
            SOAPBinding soapBinding = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPBinding.class, bindingInput.getExtensibilityElements());
            styleString = soapBinding.getStyle();
        }

        SOAPBody soapBody = JaxRpcServiceInfoBuilder.getExtensibilityElement(SOAPBody.class, bindingInput.getExtensibilityElements());
        String useString = soapBody.getUse();

        bindingStyle = BindingStyle.getBindingStyle(styleString, useString);
    }
}