Search in sources :

Example 86 with BindingOperationInfo

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

the class CorbaStreamOutInterceptor method handleMessage.

public void handleMessage(Message msg) {
    CorbaMessage message = (CorbaMessage) msg;
    orb = (org.omg.CORBA.ORB) message.get(CorbaConstants.ORB);
    Exchange exchange = message.getExchange();
    service = exchange.getEndpoint().getEndpointInfo().getService();
    typeMap = message.getCorbaTypeMap();
    BindingOperationInfo boi = exchange.getBindingOperationInfo();
    if (ContextUtils.isRequestor(message)) {
        handleOutBoundMessage(message, boi);
    } else {
        handleInBoundMessage(message, boi);
    }
    message.getInterceptorChain().add(new CorbaStreamOutEndingInterceptor());
}
Also used : Exchange(org.apache.cxf.message.Exchange) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage)

Example 87 with BindingOperationInfo

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

the class CorbaDSIServant method invoke.

public void invoke(ServerRequest request) throws CorbaBindingException {
    String opName = request.operation();
    QName requestOperation = operationMap.get(opName);
    MessageImpl msgImpl = new MessageImpl();
    msgImpl.setDestination(getDestination());
    Exchange exg = new ExchangeImpl();
    exg.put(String.class, requestOperation.getLocalPart());
    exg.put(ORB.class, getOrb());
    exg.put(ServerRequest.class, request);
    msgImpl.setExchange(exg);
    CorbaMessage msg = new CorbaMessage(msgImpl);
    msg.setCorbaTypeMap(typeMap);
    // If there's no output message part in our operation then it's a oneway op
    BindingMessageInfo bindingMsgOutputInfo = null;
    BindingOperationInfo bindingOpInfo = null;
    try {
        bindingOpInfo = this.destination.getEndPointInfo().getBinding().getOperation(requestOperation);
    } catch (Exception ex) {
        throw new CorbaBindingException("Invalid Request. Operation unknown: " + opName);
    }
    if (bindingOpInfo != null) {
        bindingMsgOutputInfo = bindingOpInfo.getOutput();
        if (bindingMsgOutputInfo == null) {
            exg.setOneWay(true);
        }
    }
    // invokes the interceptors
    getObserver().onMessage(msg);
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) QName(javax.xml.namespace.QName) CorbaMessage(org.apache.cxf.binding.corba.CorbaMessage) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) CorbaBindingException(org.apache.cxf.binding.corba.CorbaBindingException)

Example 88 with BindingOperationInfo

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

the class CorbaConduitTest method testBuildExceptionListWithExceptions.

@Test
public void testBuildExceptionListWithExceptions() throws Exception {
    CorbaConduit conduit = setupCorbaConduit(false);
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    TestUtils testUtils = new TestUtils();
    CorbaDestination destination = testUtils.getExceptionTypesTestDestination();
    EndpointInfo endpointInfo2 = destination.getEndPointInfo();
    QName name = new QName("http://schemas.apache.org/idl/except", "review_data", "");
    BindingOperationInfo bInfo = destination.getBindingInfo().getOperation(name);
    OperationType opType = bInfo.getExtensor(OperationType.class);
    CorbaTypeMap typeMap = null;
    List<TypeMappingType> corbaTypes = endpointInfo2.getService().getDescription().getExtensors(TypeMappingType.class);
    if (corbaTypes != null) {
        typeMap = CorbaUtils.createCorbaTypeMap(corbaTypes);
    }
    ExceptionList exList = conduit.getExceptionList(conduit.getOperationExceptions(opType, typeMap), message, opType);
    assertNotNull("ExceptionList is not null", exList != null);
    assertNotNull("TypeCode is not null", exList.item(0) != null);
    assertEquals("ID should be equal", exList.item(0).id(), "IDL:BadRecord:1.0");
    assertEquals("ID should be equal", exList.item(0).name(), "BadRecord");
    assertEquals("ID should be equal", exList.item(0).member_count(), 2);
    assertEquals("ID should be equal", exList.item(0).member_name(0), "reason");
    assertNotNull("Member type is not null", exList.item(0).member_type(0) != null);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Message(org.apache.cxf.message.Message) QName(javax.xml.namespace.QName) ExceptionList(org.omg.CORBA.ExceptionList) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 89 with BindingOperationInfo

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

the class ComplexClient method main.

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println("please specify wsdl");
        System.exit(1);
    }
    URL wsdlURL;
    File wsdlFile = new File(args[0]);
    if (wsdlFile.exists()) {
        wsdlURL = wsdlFile.toURI().toURL();
    } else {
        wsdlURL = new URL(args[0]);
    }
    System.out.println(wsdlURL);
    JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory.newInstance();
    Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME);
    ClientImpl clientImpl = (ClientImpl) client;
    Endpoint endpoint = clientImpl.getEndpoint();
    ServiceInfo serviceInfo = endpoint.getService().getServiceInfos().get(0);
    QName bindingName = new QName("http://Company.com/Application", "Company_ESB_Application_Biztalk_AgentDetails_4405_AgentDetails_PrtSoap");
    BindingInfo binding = serviceInfo.getBinding(bindingName);
    // {
    QName opName = new QName("http://Company.com/Application", "GetAgentDetails");
    BindingOperationInfo boi = binding.getOperation(opName);
    BindingMessageInfo inputMessageInfo = boi.getInput();
    List<MessagePartInfo> parts = inputMessageInfo.getMessageParts();
    // only one part.
    MessagePartInfo partInfo = parts.get(0);
    Class<?> partClass = partInfo.getTypeClass();
    // GetAgentDetails
    System.out.println(partClass.getCanonicalName());
    Object inputObject = partClass.newInstance();
    // Unfortunately, the slot inside of the part object is also called 'part'.
    // this is the descriptor for get/set part inside the GetAgentDetails class.
    PropertyDescriptor partPropertyDescriptor = new PropertyDescriptor("part", partClass);
    // This is the type of the class which really contains all the parameter information.
    // AgentWSRequest
    Class<?> partPropType = partPropertyDescriptor.getPropertyType();
    System.out.println(partPropType.getCanonicalName());
    Object inputPartObject = partPropType.newInstance();
    partPropertyDescriptor.getWriteMethod().invoke(inputObject, inputPartObject);
    PropertyDescriptor numberPropertyDescriptor = new PropertyDescriptor("agentNumber", partPropType);
    numberPropertyDescriptor.getWriteMethod().invoke(inputPartObject, new Integer(314159));
    Object[] result = client.invoke(opName, inputObject);
    Class<?> resultClass = result[0].getClass();
    // GetAgentDetailsResponse
    System.out.println(resultClass.getCanonicalName());
    PropertyDescriptor resultDescriptor = new PropertyDescriptor("agentWSResponse", resultClass);
    Object wsResponse = resultDescriptor.getReadMethod().invoke(result[0]);
    Class<?> wsResponseClass = wsResponse.getClass();
    System.out.println(wsResponseClass.getCanonicalName());
    PropertyDescriptor agentNameDescriptor = new PropertyDescriptor("agentName", wsResponseClass);
    String agentName = (String) agentNameDescriptor.getReadMethod().invoke(wsResponse);
    System.out.println("Agent name: " + agentName);
}
Also used : JaxWsDynamicClientFactory(org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) PropertyDescriptor(java.beans.PropertyDescriptor) QName(javax.xml.namespace.QName) ClientImpl(org.apache.cxf.endpoint.ClientImpl) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) URL(java.net.URL) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) Client(org.apache.cxf.endpoint.Client) File(java.io.File)

Example 90 with BindingOperationInfo

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

the class ReflectionServiceFactoryTest method testServerFactoryBean.

@Test
public void testServerFactoryBean() throws Exception {
    Service service = createService(true);
    assertEquals("test", service.get("test"));
    ServerFactoryBean svrBean = new ServerFactoryBean();
    svrBean.setAddress("http://localhost/Hello");
    svrBean.setServiceFactory(serviceFactory);
    svrBean.setServiceBean(new HelloServiceImpl());
    svrBean.setBus(getBus());
    Map<String, Object> props = new HashMap<>();
    props.put("test", "test");
    serviceFactory.setProperties(props);
    svrBean.setProperties(props);
    Server server = svrBean.create();
    assertNotNull(server);
    Map<QName, Endpoint> eps = service.getEndpoints();
    assertEquals(1, eps.size());
    Endpoint ep = eps.values().iterator().next();
    EndpointInfo endpointInfo = ep.getEndpointInfo();
    assertEquals("test", ep.get("test"));
    BindingInfo b = endpointInfo.getService().getBindings().iterator().next();
    assertTrue(b instanceof SoapBindingInfo);
    SoapBindingInfo sb = (SoapBindingInfo) b;
    assertEquals("HelloServiceSoapBinding", b.getName().getLocalPart());
    assertEquals("document", sb.getStyle());
    assertEquals(4, b.getOperations().size());
    BindingOperationInfo bop = b.getOperations().iterator().next();
    SoapOperationInfo sop = bop.getExtensor(SoapOperationInfo.class);
    assertNotNull(sop);
    assertEquals("", sop.getAction());
    assertEquals("document", sop.getStyle());
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) Server(org.apache.cxf.endpoint.Server) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) ServerFactoryBean(org.apache.cxf.frontend.ServerFactoryBean) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) Endpoint(org.apache.cxf.endpoint.Endpoint) BindingInfo(org.apache.cxf.service.model.BindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapBindingInfo(org.apache.cxf.binding.soap.model.SoapBindingInfo) SoapOperationInfo(org.apache.cxf.binding.soap.model.SoapOperationInfo) Test(org.junit.Test)

Aggregations

BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)214 QName (javax.xml.namespace.QName)82 BindingInfo (org.apache.cxf.service.model.BindingInfo)57 Test (org.junit.Test)55 Exchange (org.apache.cxf.message.Exchange)50 OperationInfo (org.apache.cxf.service.model.OperationInfo)47 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)42 Endpoint (org.apache.cxf.endpoint.Endpoint)41 Message (org.apache.cxf.message.Message)36 MessagePartInfo (org.apache.cxf.service.model.MessagePartInfo)36 BindingMessageInfo (org.apache.cxf.service.model.BindingMessageInfo)32 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)31 Service (org.apache.cxf.service.Service)29 Fault (org.apache.cxf.interceptor.Fault)24 MessageInfo (org.apache.cxf.service.model.MessageInfo)24 MessageContentsList (org.apache.cxf.message.MessageContentsList)23 Method (java.lang.reflect.Method)22 SoapOperationInfo (org.apache.cxf.binding.soap.model.SoapOperationInfo)22 ArrayList (java.util.ArrayList)21 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)16