Search in sources :

Example 96 with BindingInfo

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

the class AbstractSTSTokenTest method prepareMessage.

static MessageImpl prepareMessage(Bus bus, STSClient stsClient, String serviceAddress) throws EndpointException {
    MessageImpl message = new MessageImpl();
    message.put(SecurityConstants.STS_CLIENT, stsClient);
    message.put(Message.ENDPOINT_ADDRESS, serviceAddress);
    Exchange exchange = new ExchangeImpl();
    ServiceInfo si = new ServiceInfo();
    si.setName(new QName("http://www.apache.org", "ServiceName"));
    Service s = new ServiceImpl(si);
    EndpointInfo ei = new EndpointInfo();
    ei.setName(new QName("http://www.apache.org", "EndpointName"));
    Endpoint ep = new EndpointImpl(bus, s, ei);
    ei.setBinding(new BindingInfo(si, null));
    message.setExchange(exchange);
    exchange.put(Endpoint.class, ep);
    return message;
}
Also used : Exchange(org.apache.cxf.message.Exchange) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) QName(javax.xml.namespace.QName) ServiceImpl(org.apache.cxf.service.ServiceImpl) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 97 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project tesb-rt-se by Talend.

the class CXFTestStubs method createBindingStub.

public static Binding createBindingStub(String bindingId) {
    BindingInfo bindingInfo = EasyMock.createNiceMock(BindingInfo.class);
    expect(bindingInfo.getBindingId()).andStubReturn(bindingId);
    Binding binding = EasyMock.createNiceMock(Binding.class);
    expect(binding.getBindingInfo()).andStubReturn(bindingInfo);
    expect(binding.getBindingInfo()).andStubReturn(bindingInfo);
    EasyMock.replay(bindingInfo, binding);
    return binding;
}
Also used : Binding(org.apache.cxf.binding.Binding) BindingInfo(org.apache.cxf.service.model.BindingInfo)

Example 98 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project tesb-rt-se by Talend.

the class RequestCallbackInInterceptor method fillCallContext.

public static void fillCallContext(CallContext callContext, SoapMessage message) {
    if (callContext.getOperationName() == null) {
        callContext.setOperationName((QName) message.get(Message.WSDL_OPERATION));
    }
    callContext.setPortTypeName((QName) message.get(Message.WSDL_INTERFACE));
    callContext.setServiceName((QName) message.get(Message.WSDL_SERVICE));
    final BindingInfo bi = message.getExchange().getBinding().getBindingInfo();
    callContext.setBindingId(bi == null ? "http://schemas.xmlsoap.org/wsdl/soap/" : bi.getBindingId());
    URL wsdlLocation = resolveCallbackWsdlLocation(callContext.getServiceName(), message);
    if (wsdlLocation != null) {
        callContext.setWsdlLocation(wsdlLocation);
    }
    String flowId = FlowIdHelper.getFlowId(message);
    if (flowId != null && !flowId.isEmpty()) {
        callContext.setFlowId(flowId);
    }
}
Also used : BindingInfo(org.apache.cxf.service.model.BindingInfo) URL(java.net.URL)

Example 99 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project fabric8 by fabric8io.

the class ManagedApi method getJSONSchema.

@ManagedOperation(description = "get the JSON schema from a given endpoint", currencyTimeLimit = 60)
public String getJSONSchema() {
    String ret = "";
    if (!isWSDL()) {
        Set<Class<?>> resourceTypes = getRESTResourceTypes();
        if (resourceTypes != null) {
            try {
                ret = ret + getBeginIndentionWithReturn(1) + "\"" + "definitions" + "\" " + " : {" + getEol();
                for (Class<?> cls : resourceTypes) {
                    if (JsonSchemaLookup.getSingleton().getSchemaForClass(cls).length() > 0) {
                        ret = ret + getIndention(2) + "\"" + cls.getName() + "\" : " + getEol();
                        ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(cls), 3)) + "," + getEol();
                    }
                }
                ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(1);
                ret = ret + getEndIndentionWithReturn(0);
            } catch (Throwable e) {
                LOG.log(Level.WARNING, "getJSONSchema failed.", e);
            }
        }
    } else {
        try {
            for (ServiceInfo serviceInfo : endpoint.getService().getServiceInfos()) {
                for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
                    ret = ret + getBeginIndentionWithReturn(1) + "\"operations\" : " + getBeginIndentionWithReturn(0);
                    for (BindingOperationInfo boi : bindingInfo.getOperations()) {
                        ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getName().getLocalPart() + "\" " + " : " + getBeginIndentionWithReturn(3);
                        if (boi.getInput() != null && boi.getInput().getMessageParts() != null) {
                            ret = ret + "\"input\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(3) + "," + getEol();
                        }
                        if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null) {
                            ret = ret + getIndention(3) + "\"output\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(3);
                        }
                        ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(2) + "," + getEol();
                    }
                    if (ret.length() > 0) {
                        ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(1) + ",";
                    }
                    Set<String> addedType = new HashSet<String>();
                    ret = ret + getEol() + getIndention(1) + "\"definitions\" : " + getBeginIndentionWithReturn(0);
                    for (BindingOperationInfo boi : bindingInfo.getOperations()) {
                        if (boi.getInput() != null && boi.getInput().getMessageParts() != null && !addedType.contains(boi.getOperationInfo().getInput().getName().getLocalPart())) {
                            ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
                            for (MessagePartInfo mpi : boi.getInput().getMessageParts()) {
                                Class<?> partClass = mpi.getTypeClass();
                                if (partClass != null) {
                                    ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
                                }
                            }
                            ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + "," + getEol();
                            addedType.add(boi.getOperationInfo().getInput().getName().getLocalPart());
                        }
                        if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null && !addedType.contains(boi.getOperationInfo().getOutput().getName().getLocalPart())) {
                            ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
                            for (MessagePartInfo mpi : boi.getOutput().getMessageParts()) {
                                Class<?> partClass = mpi.getTypeClass();
                                if (partClass != null) {
                                    ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
                                }
                            }
                            ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + "," + getEol();
                            addedType.add(boi.getOperationInfo().getOutput().getName().getLocalPart());
                        }
                    }
                    if (ret.length() > 0) {
                        ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturn(1);
                    }
                    if (ret.length() > 0) {
                        ret = rollbackColon(ret) + getEndIndentionWithReturn(0);
                    }
                }
            }
        } catch (Throwable e) {
            LOG.log(Level.WARNING, "getJSONSchema failed.", e);
        }
    }
    return ret;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) HashSet(java.util.HashSet) ManagedOperation(org.apache.cxf.management.annotation.ManagedOperation)

Example 100 with BindingInfo

use of org.apache.cxf.service.model.BindingInfo in project fabric8 by fabric8io.

the class ManagedApi method getJSONSchemaForOperation.

@ManagedOperation(description = "get the JSON schema from a given soap endpoint for a given operation", currencyTimeLimit = 60)
public String getJSONSchemaForOperation(String operationName) {
    if (!isWSDL()) {
        return null;
    }
    String ret = "";
    for (ServiceInfo serviceInfo : endpoint.getService().getServiceInfos()) {
        for (BindingInfo bindingInfo : serviceInfo.getBindings()) {
            for (BindingOperationInfo boi : bindingInfo.getOperations()) {
                if (operationName.equals(boi.getOperationInfo().getName().getLocalPart())) {
                    ret = ret + getBeginIndentionWithReturn(1) + "\"" + boi.getOperationInfo().getName().getLocalPart() + "\" " + " : " + getBeginIndentionWithReturn(2);
                    if (boi.getInput() != null && boi.getInput().getMessageParts() != null) {
                        ret = ret + "\"input\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(2) + "," + getEol();
                    }
                    if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null) {
                        ret = ret + getIndention(2) + "\"output\" : " + getBeginIndentionWithReturn(4) + "\"type\" : \"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\"" + getEndIndentionWithReturn(2);
                    }
                    ret = rollbackColon(ret) + getEndIndentionWithReturn(1) + ",";
                    ret = ret + getEol() + getIndention(1) + "\"definitions\" : " + getBeginIndentionWithReturn(2);
                    if (boi.getInput() != null && boi.getInput().getMessageParts() != null) {
                        ret = ret + "\"" + boi.getOperationInfo().getInput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
                        for (MessagePartInfo mpi : boi.getInput().getMessageParts()) {
                            Class<?> partClass = mpi.getTypeClass();
                            if (partClass != null) {
                                ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
                            }
                        }
                        ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + "," + getEol();
                    }
                    if (boi.getOutput() != null && boi.getOutput().getMessageParts() != null) {
                        ret = ret + getIndention(2) + "\"" + boi.getOperationInfo().getOutput().getName().getLocalPart() + "\" : " + getBeginIndentionWithReturnForList(0);
                        for (MessagePartInfo mpi : boi.getOutput().getMessageParts()) {
                            Class<?> partClass = mpi.getTypeClass();
                            if (partClass != null) {
                                ret = ret + rollbackEol(reformatIndent(JsonSchemaLookup.getSingleton().getSchemaForClass(partClass), 3)) + "," + getEol();
                            }
                        }
                        ret = rollbackColon(rollbackEol(ret)) + getEndIndentionWithReturnForList(2) + ",";
                    }
                }
            }
            if (ret.length() > 0) {
                ret = rollbackColon(ret) + getEndIndentionWithReturn(1);
            }
            if (ret.length() > 0) {
                ret = rollbackColon(ret) + getEndIndentionWithReturn(0);
            }
        }
    }
    return ret;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ManagedOperation(org.apache.cxf.management.annotation.ManagedOperation)

Aggregations

BindingInfo (org.apache.cxf.service.model.BindingInfo)103 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)65 QName (javax.xml.namespace.QName)45 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)44 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)35 Test (org.junit.Test)29 Endpoint (org.apache.cxf.endpoint.Endpoint)28 OperationInfo (org.apache.cxf.service.model.OperationInfo)21 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)20 Service (org.apache.cxf.service.Service)18 SoapBindingInfo (org.apache.cxf.binding.soap.model.SoapBindingInfo)17 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)17 Exchange (org.apache.cxf.message.Exchange)15 Message (org.apache.cxf.message.Message)13 ArrayList (java.util.ArrayList)11 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)11 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)11 MessageImpl (org.apache.cxf.message.MessageImpl)11 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)9 Bus (org.apache.cxf.Bus)8