Search in sources :

Example 66 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class STSUtils method addCancelOperation.

private static OperationInfo addCancelOperation(InterfaceInfo ii, String namespace, String servNamespace) {
    OperationInfo oi = ii.addOperation(new QName(servNamespace, "CancelSecurityToken"));
    MessageInfo mii = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenMsg"), MessageInfo.Type.INPUT);
    oi.setInput("CancelSecurityTokenMsg", mii);
    MessagePartInfo mpi = mii.addMessagePart("request");
    mpi.setElementQName(new QName(namespace, "RequestSecurityToken"));
    MessageInfo mio = oi.createMessage(new QName(servNamespace, "CancelSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT);
    oi.setOutput("CancelSecurityTokenResponseMsg", mio);
    mpi = mio.addMessagePart("response");
    if (WST_NS_05_02.equals(namespace)) {
        mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse"));
    } else {
        mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection"));
    }
    return oi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 67 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class STSUtils method createSTSEndpoint.

// CHECKSTYLE:OFF
private static Endpoint createSTSEndpoint(Bus bus, String namespace, String transportId, String location, String soapVersion, Policy policy, QName epName, boolean sc) throws BusException, EndpointException {
    // CHECKSTYLE:ON
    Service service = null;
    String ns = namespace + "/wsdl";
    ServiceInfo si = new ServiceInfo();
    QName iName = new QName(ns, sc ? "SecureConversationTokenService" : "SecurityTokenService");
    si.setName(iName);
    InterfaceInfo ii = new InterfaceInfo(si, iName);
    OperationInfo ioi = addIssueOperation(ii, namespace, ns);
    OperationInfo coi = addCancelOperation(ii, namespace, ns);
    OperationInfo roi = addRenewOperation(ii, namespace, ns);
    si.setInterface(ii);
    service = new ServiceImpl(si);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    BindingFactory bindingFactory = bfm.getBindingFactory(soapVersion);
    BindingInfo bi = bindingFactory.createBindingInfo(service, soapVersion, null);
    si.addBinding(bi);
    if (transportId == null) {
        ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
        ConduitInitiator ci = cim.getConduitInitiatorForUri(location);
        transportId = ci.getTransportIds().get(0);
    }
    EndpointInfo ei = new EndpointInfo(si, transportId);
    ei.setBinding(bi);
    ei.setName(epName == null ? iName : epName);
    ei.setAddress(location);
    si.addEndpoint(ei);
    if (policy != null) {
        ei.addExtensor(policy);
    }
    BindingOperationInfo boi = bi.getOperation(ioi);
    SoapOperationInfo soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT" : "/RST/Issue"));
    boi = bi.getOperation(coi);
    soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT/Cancel" : "/RST/Cancel"));
    boi = bi.getOperation(roi);
    soi = boi.getExtensor(SoapOperationInfo.class);
    if (soi == null) {
        soi = new SoapOperationInfo();
        boi.addExtensor(soi);
    }
    soi.setAction(namespace + (sc ? "/RST/SCT/Renew" : "/RST/Renew"));
    service.setDataBinding(new SourceDataBinding());
    return new EndpointImpl(bus, service, ei);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) QName(javax.xml.namespace.QName) ServiceImpl(org.apache.cxf.service.ServiceImpl) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Service(org.apache.cxf.service.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 68 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class STSUtils method addRenewOperation.

private static OperationInfo addRenewOperation(InterfaceInfo ii, String namespace, String servNamespace) {
    OperationInfo oi = ii.addOperation(new QName(servNamespace, "RenewSecurityToken"));
    MessageInfo mii = oi.createMessage(new QName(servNamespace, "RenewSecurityTokenMsg"), MessageInfo.Type.INPUT);
    oi.setInput("RenewSecurityTokenMsg", mii);
    MessagePartInfo mpi = mii.addMessagePart("request");
    mpi.setElementQName(new QName(namespace, "RequestSecurityToken"));
    MessageInfo mio = oi.createMessage(new QName(servNamespace, "RenewSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT);
    oi.setOutput("RenewSecurityTokenResponseMsg", mio);
    mpi = mio.addMessagePart("response");
    if (WST_NS_05_02.equals(namespace)) {
        mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse"));
    } else {
        mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection"));
    }
    return oi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 69 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class STSUtils method addIssueOperation.

private static OperationInfo addIssueOperation(InterfaceInfo ii, String namespace, String servNamespace) {
    OperationInfo oi = ii.addOperation(new QName(servNamespace, "RequestSecurityToken"));
    MessageInfo mii = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenMsg"), MessageInfo.Type.INPUT);
    oi.setInput("RequestSecurityTokenMsg", mii);
    MessagePartInfo mpi = mii.addMessagePart("request");
    mpi.setElementQName(new QName(namespace, "RequestSecurityToken"));
    MessageInfo mio = oi.createMessage(new QName(servNamespace, "RequestSecurityTokenResponseMsg"), MessageInfo.Type.OUTPUT);
    oi.setOutput("RequestSecurityTokenResponseMsg", mio);
    mpi = mio.addMessagePart("response");
    if (WST_NS_05_02.equals(namespace)) {
        mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponse"));
    } else {
        mpi.setElementQName(new QName(namespace, "RequestSecurityTokenResponseCollection"));
    }
    return oi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) QName(javax.xml.namespace.QName) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo)

Example 70 with OperationInfo

use of org.apache.cxf.service.model.OperationInfo in project cxf by apache.

the class ServiceWSDLBuilder method buildPortTypeOperation.

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);
    }
}
Also used : OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Input(javax.wsdl.Input) BindingInput(javax.wsdl.BindingInput) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Message(javax.wsdl.Message) BindingOutput(javax.wsdl.BindingOutput) Output(javax.wsdl.Output) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Aggregations

OperationInfo (org.apache.cxf.service.model.OperationInfo)135 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)87 QName (javax.xml.namespace.QName)58 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)44 MessageInfo (org.apache.cxf.service.model.MessageInfo)40 Test (org.junit.Test)38 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)36 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)31 Method (java.lang.reflect.Method)25 Endpoint (org.apache.cxf.endpoint.Endpoint)24 Service (org.apache.cxf.service.Service)22 BindingInfo (org.apache.cxf.service.model.BindingInfo)21 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)19 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)17 Exchange (org.apache.cxf.message.Exchange)17 ArrayList (java.util.ArrayList)13 UnwrappedOperationInfo (org.apache.cxf.service.model.UnwrappedOperationInfo)13 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)12 Fault (org.apache.cxf.interceptor.Fault)10 Message (org.apache.cxf.message.Message)10