Java源码示例:javax.wsdl.OperationType

示例1
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;
}
 
示例2
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;
}
 
示例3
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;
}
 
示例4
@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());
}
 
示例5
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;
}
 
示例6
private boolean isRequestResponse(JavaMethod method) {
    return method.getStyle() == OperationType.REQUEST_RESPONSE;
}
 
示例7
public OperationType getStyle() {
    return this.style;
}
 
示例8
public void setStyle(OperationType ot) {
    this.style = ot;
}
 
示例9
public boolean isOneWay() {
    return OperationType.ONE_WAY.equals(getStyle());
}
 
示例10
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);
    }
}
 
示例11
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());
        }
    }