javax.wsdl.OperationType Java Examples

The following examples show how to use javax.wsdl.OperationType. 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: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private Operation addOWOperation2PT( Definition def, PortType pt, OneWayOperationDeclaration op ) {
	Operation wsdlOp = def.createOperation();

	wsdlOp.setName( op.id() );
	wsdlOp.setStyle( OperationType.ONE_WAY );
	wsdlOp.setUndefined( false );

	Input in = def.createInput();
	Message msg_req = addRequestMessage( localDef, op );
	msg_req.setUndefined( false );
	in.setMessage( msg_req );
	wsdlOp.setInput( in );
	wsdlOp.setUndefined( false );

	pt.addOperation( wsdlOp );

	return wsdlOp;
}
 
Example #2
Source File: WSDLDocCreator.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Operation addRROperation2PT( Definition def, PortType pt, RequestResponseOperationDeclaration op ) {
	Operation wsdlOp = def.createOperation();

	wsdlOp.setName( op.id() );
	wsdlOp.setStyle( OperationType.REQUEST_RESPONSE );
	wsdlOp.setUndefined( false );

	// creating input
	Input in = def.createInput();
	Message msg_req = addRequestMessage( localDef, op );
	in.setMessage( msg_req );
	wsdlOp.setInput( in );

	// creating output
	Output out = def.createOutput();
	Message msg_resp = addResponseMessage( localDef, op );
	out.setMessage( msg_resp );
	wsdlOp.setOutput( out );

	// creating faults
	for( Entry< String, TypeDefinition > curFault : op.faults().entrySet() ) {
		Fault fault = localDef.createFault();
		fault.setName( curFault.getKey() );
		Message flt_msg = addFaultMessage( localDef, curFault.getValue() );
		fault.setMessage( flt_msg );
		wsdlOp.addFault( fault );

	}
	pt.addOperation( wsdlOp );

	return wsdlOp;
}
 
Example #3
Source File: MethodMapper.java    From cxf with Apache License 2.0 5 votes vote down vote up
public JavaMethod map(OperationInfo operation) {
    JavaMethod method = new JavaMethod();
    // set default Document Bare style
    method.setSoapStyle(javax.jws.soap.SOAPBinding.Style.DOCUMENT);

    String operationName = operation.getName().getLocalPart();

    method.setName(ProcessorUtil.mangleNameToVariableName(operationName));
    method.setOperationName(operationName);

    JAXWSBinding opBinding = operation.getExtensor(JAXWSBinding.class);
    if (opBinding != null
        && opBinding.getMethodName() != null) {
        method.setName(opBinding.getMethodName());
    }

    if (opBinding != null
        && opBinding.getMethodJavaDoc() != null) {
        method.setJavaDoc(opBinding.getMethodJavaDoc());
    } else {
        method.setJavaDoc(operation.getDocumentation());
    }

    if (operation.isOneWay()) {
        method.setStyle(OperationType.ONE_WAY);
    } else {
        method.setStyle(OperationType.REQUEST_RESPONSE);
    }

    method.setWrapperStyle(operation.isUnwrappedCapable());

    return method;
}
 
Example #4
Source File: MethodMapperTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testMap() throws Exception {
    JavaMethod method = new MethodMapper().map(getOperation());
    assertNotNull(method);

    assertEquals(javax.jws.soap.SOAPBinding.Style.DOCUMENT, method.getSoapStyle());
    assertEquals("operationTest", method.getName());
    assertEquals("OperationTest", method.getOperationName());
    assertEquals(OperationType.REQUEST_RESPONSE, method.getStyle());
    assertFalse(method.isWrapperStyle());
    assertFalse(method.isOneWay());
}
 
Example #5
Source File: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
private String getOutputMessageNamespace( String operationName )
	throws IOException {
	String messageNamespace = "";
	Port port = getWSDLPort();
	if( port == null ) {
		if( hasParameter( "namespace" ) ) {
			messageNamespace = getStringParameter( "namespace" );
		}
	} else {
		Operation operation = port.getBinding().getPortType().getOperation( operationName, null, null );
		List< ExtensibilityElement > listExt;
		Message soapMessage;
		if( received ) {
			// We are sending a response
			if( operation.getStyle().equals( OperationType.ONE_WAY ) ) {
				soapMessage = operation.getInput().getMessage();
				listExt = getWSDLPort().getBinding().getBindingOperation( operationName, null, null )
					.getBindingInput().getExtensibilityElements();
			} else {
				soapMessage = operation.getOutput().getMessage();
				listExt = getWSDLPort().getBinding().getBindingOperation( operationName, null, null )
					.getBindingOutput().getExtensibilityElements();
			}
		} else {
			// We are sending a request
			soapMessage = operation.getInput().getMessage();
			listExt = getWSDLPort().getBinding().getBindingOperation( operationName, null, null ).getBindingInput()
				.getExtensibilityElements();
		}
		for( ExtensibilityElement element : listExt ) {
			if( element instanceof SOAPBodyImpl ) {
				SOAPBodyImpl sBodyImpl = (SOAPBodyImpl) element;
				if( sBodyImpl.getParts() != null && sBodyImpl.getParts().size() > 0 ) {
					String partName = sBodyImpl.getParts().get( 0 ).toString();
					messageNamespace = soapMessage.getPart( partName ).getElementName().getNamespaceURI();
				} else {
					Part part =
						((Entry< String, Part >) soapMessage.getParts().entrySet().iterator().next()).getValue();
					messageNamespace = part.getElementName().getNamespaceURI();
				}
			}
		}
	}
	return messageNamespace;
}
 
Example #6
Source File: ParameterProcessor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private boolean isRequestResponse(JavaMethod method) {
    return method.getStyle() == OperationType.REQUEST_RESPONSE;
}
 
Example #7
Source File: JavaMethod.java    From cxf with Apache License 2.0 4 votes vote down vote up
public OperationType getStyle() {
    return this.style;
}
 
Example #8
Source File: JavaMethod.java    From cxf with Apache License 2.0 4 votes vote down vote up
public void setStyle(OperationType ot) {
    this.style = ot;
}
 
Example #9
Source File: JavaMethod.java    From cxf with Apache License 2.0 4 votes vote down vote up
public boolean isOneWay() {
    return OperationType.ONE_WAY.equals(getStyle());
}
 
Example #10
Source File: ServiceWSDLBuilder.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected void buildPortTypeOperation(PortType portType,
                                      Collection<OperationInfo> operationInfos,
                                      final Definition def) {
    for (OperationInfo operationInfo : operationInfos) {
        Operation operation = null;
        try {
            operation = operationInfo.getProperty(
                WSDLServiceBuilder.WSDL_OPERATION, Operation.class);
        } catch (ClassCastException e) {
            // do nothing
        }

        if (operation == null) {
            operation = def.createOperation();
            addDocumentation(operation, operationInfo.getDocumentation());
            operation.setUndefined(false);
            operation.setName(operationInfo.getName().getLocalPart());
            addNamespace(operationInfo.getName().getNamespaceURI(), def);
            if (operationInfo.isOneWay()) {
                operation.setStyle(OperationType.ONE_WAY);
            }
            addExtensibilityElements(def, operation, getWSDL11Extensors(operationInfo));
            Input input = def.createInput();
            addDocumentation(input, operationInfo.getInput().getDocumentation());
            input.setName(operationInfo.getInputName());
            Message message = def.createMessage();
            buildMessage(message, operationInfo.getInput(), def);
            this.addExtensibilityAttributes(def, input, getInputExtensionAttributes(operationInfo));
            this.addExtensibilityElements(def, input, getWSDL11Extensors(operationInfo.getInput()));
            input.setMessage(message);
            operation.setInput(input);
            operation.setParameterOrdering(operationInfo.getParameterOrdering());

            if (operationInfo.getOutput() != null) {
                Output output = def.createOutput();
                addDocumentation(output, operationInfo.getOutput().getDocumentation());
                output.setName(operationInfo.getOutputName());
                message = def.createMessage();
                buildMessage(message, operationInfo.getOutput(), def);
                this.addExtensibilityAttributes(def, output, getOutputExtensionAttributes(operationInfo));
                this.addExtensibilityElements(def, output, getWSDL11Extensors(operationInfo.getOutput()));
                output.setMessage(message);
                operation.setOutput(output);
            }
            //loop to add fault
            Collection<FaultInfo> faults = operationInfo.getFaults();
            Fault fault = null;
            for (FaultInfo faultInfo : faults) {
                fault = def.createFault();
                addDocumentation(fault, faultInfo.getDocumentation());
                fault.setName(faultInfo.getFaultName().getLocalPart());
                message = def.createMessage();
                buildMessage(message, faultInfo, def);
                this.addExtensibilityAttributes(def, fault, faultInfo.getExtensionAttributes());
                this.addExtensibilityElements(def, fault, getWSDL11Extensors(faultInfo));
                fault.setMessage(message);
                operation.addFault(fault);
            }
        }
        portType.addOperation(operation);
    }
}
 
Example #11
Source File: ServiceEndpointMethodInterceptor.java    From tomee with Apache License 2.0 4 votes vote down vote up
private Object doIntercept(Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        int index = methodProxy.getSuperIndex();
        OperationInfo operationInfo = operations[index];
        if (operationInfo == null) {
            throw new ServerRuntimeException("Operation not mapped: " + method.getName() + " index: " + index + "\n OperationInfos: " + Arrays.asList(operations));
        }
        stub.checkCachedEndpoint();

        Call call = stub.createCall();

        operationInfo.prepareCall(call);

        stub.setUpCall(call);
        if (credentialsName != null) {
            throw new UnsupportedOperationException("Client side auth is not implementd");
//            Subject subject = ContextManager.getNextCaller();
//            if (subject == null) {
//                throw new IllegalStateException("Subject missing but authentication turned on");
//            } else {
//                Set creds = subject.getPrivateCredentials(NamedUsernamePasswordCredential.class);
//                boolean found = false;
//                for (Iterator iterator = creds.iterator(); iterator.hasNext();) {
//                    NamedUsernamePasswordCredential namedUsernamePasswordCredential = (NamedUsernamePasswordCredential) iterator.next();
//                    if (credentialsName.equals(namedUsernamePasswordCredential.getName())) {
//                        call.setUsername(namedUsernamePasswordCredential.getUsername());
//                        call.setPassword(new String(namedUsernamePasswordCredential.getPassword()));
//                        found = true;
//                        break;
//                    }
//                }
//                if (!found) {
//                    throw new IllegalStateException("no NamedUsernamePasswordCredential found for name " + credentialsName);
//                }
//            }
        }
        Object response = null;
        List parameterDescs = operationInfo.getOperationDesc().getParameters();
        Object[] unwrapped = extractFromHolders(objects, parameterDescs, operationInfo.getOperationDesc().getNumInParams());
        if (operationInfo.getOperationDesc().getMep() == OperationType.REQUEST_RESPONSE) {
            try {
                response = call.invoke(unwrapped);
            } catch (RemoteException e) {
                throw operationInfo.unwrapFault(e);
            }

            if (response instanceof RemoteException) {
                throw operationInfo.unwrapFault((RemoteException) response);
            } else {
                stub.extractAttachments(call);
                Map outputParameters = call.getOutputParams();
                putInHolders(outputParameters, objects, parameterDescs);
                Class returnType = operationInfo.getOperationDesc().getReturnClass();
                //return type should never be null... but we are not objecting if wsdl-return-value-mapping is not set.
                if (response == null || returnType == null || returnType.isAssignableFrom(response.getClass())) {
                    return response;
                } else {
                    return JavaUtils.convert(response, returnType);
                }
            }
        } else if (operationInfo.getOperationDesc().getMep() == OperationType.ONE_WAY) {
            //one way
            call.invokeOneWay(unwrapped);
            return null;
        } else {
            throw new ServerRuntimeException("Invalid messaging style: " + operationInfo.getOperationDesc().getMep());
        }
    }