Java Code Examples for org.apache.cxf.service.model.BindingInfo#getOperation()

The following examples show how to use org.apache.cxf.service.model.BindingInfo#getOperation() . 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: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testBare() throws Exception {
    setUpWSDL(BARE_WSDL_PATH, 0);
    BindingInfo bindingInfo = null;
    bindingInfo = serviceInfo.getBindings().iterator().next();
    Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
    assertNotNull(bindingOperationInfos);
    assertEquals(bindingOperationInfos.size(), 1);
    LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    BindingOperationInfo greetMe = bindingInfo.getOperation(name);
    assertNotNull(greetMe);
    assertEquals("greetMe OperationInfo name error", greetMe.getName(), name);
    assertFalse("greetMe should be a Unwrapped operation ", greetMe.isUnwrappedCapable());

    assertNotNull(serviceInfo.getXmlSchemaCollection());
    control.verify();
}
 
Example 2
Source File: ColocMessageObserver.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void setExchangeProperties(Exchange exchange, Message m) {
    exchange.put(Bus.class, bus);
    exchange.put(Endpoint.class, endpoint);
    exchange.put(Service.class, endpoint.getService());
    exchange.put(Binding.class, endpoint.getBinding());

    //Setup the BindingOperationInfo
    QName opName = (QName) m.get(Message.WSDL_OPERATION);
    BindingInfo bi = endpoint.getEndpointInfo().getBinding();
    BindingOperationInfo boi = bi.getOperation(opName);
    if (boi != null && boi.isUnwrapped()) {
        boi = boi.getWrappedOperation();
    }

    exchange.put(BindingOperationInfo.class, boi);
}
 
Example 3
Source File: MustUnderstandInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleMessageWithSoapHeader12Param() throws Exception {
    prepareSoapMessage("test-soap-12-header.xml");
    dsi.getUnderstoodHeaders().add(RESERVATION);
    ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-12-header.wsdl")
        .toString());

    BindingInfo binding = serviceInfo.getBinding(new QName("http://org.apache.cxf/headers",
                                                           "headerTesterSOAPBinding"));
    BindingOperationInfo bop = binding.getOperation(new QName("http://org.apache.cxf/headers",
                                                              "inHeader"));
    soapMessage.getExchange().put(BindingOperationInfo.class, bop);

    soapMessage.getInterceptorChain().doIntercept(soapMessage);
    assertTrue("DummaySoapInterceptor getRoles has been called!", dsi.isCalledGetRoles());
    assertTrue("DummaySoapInterceptor getUnderstood has been called!", dsi.isCalledGetUnderstood());
}
 
Example 4
Source File: MustUnderstandInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testHandleMessageWithSoapHeader11Param() throws Exception {
    prepareSoapMessage("test-soap-header.xml");
    dsi.getUnderstoodHeaders().add(RESERVATION);

    ServiceInfo serviceInfo = getMockedServiceModel(getClass().getResource("test-soap-header.wsdl")
        .toString());

    BindingInfo binding = serviceInfo.getBinding(new QName("http://org.apache.cxf/headers",
                                                           "headerTesterSOAPBinding"));
    BindingOperationInfo bop = binding.getOperation(new QName("http://org.apache.cxf/headers",
                                                              "inHeader"));
    soapMessage.getExchange().put(BindingOperationInfo.class, bop);

    soapMessage.getInterceptorChain().doIntercept(soapMessage);
    assertTrue("DummaySoapInterceptor getRoles has been called!", dsi.isCalledGetRoles());
    assertTrue("DummaySoapInterceptor getUnderstood has been called!", dsi.isCalledGetUnderstood());
}
 
Example 5
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testWrapOut() throws Exception {
    GreetMe greetMe = new GreetMe();
    greetMe.setRequestType("tli");
    params.add(greetMe);
    common("/wsdl/hello_world_xml_wrapped.wsdl", new QName(wrapNs, "XMLPort"), GreetMe.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(wrapNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(wrapNs, "greetMe"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);
    assertEquals(wrapGreetMeQName.getNamespaceURI(), dxr.getNamespaceURI());
    assertEquals(wrapGreetMeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(greetMe.getRequestType(), dxr.getText());
}
 
Example 6
Source File: RMCaptureOutInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void setTerminateSequence(Message msg, Identifier identifier, ProtocolVariation protocol)
    throws RMException {
    TerminateSequenceType ts = new TerminateSequenceType();
    ts.setIdentifier(identifier);
    MessageContentsList contents =
        new MessageContentsList(new Object[]{protocol.getCodec().convertToSend(ts)});
    msg.setContent(List.class, contents);

    // create a new exchange for this output-only exchange
    Exchange newex = new ExchangeImpl();
    Exchange oldex = msg.getExchange();

    newex.put(Bus.class, oldex.getBus());
    newex.put(Endpoint.class, oldex.getEndpoint());
    newex.put(Service.class, oldex.getEndpoint().getService());
    newex.put(Binding.class, oldex.getEndpoint().getBinding());
    newex.setConduit(oldex.getConduit(msg));
    newex.setDestination(oldex.getDestination());

    //Setup the BindingOperationInfo
    RMEndpoint rmep = getManager().getReliableEndpoint(msg);
    OperationInfo oi = rmep.getEndpoint(protocol).getEndpointInfo().getService().getInterface()
        .getOperation(protocol.getConstants().getTerminateSequenceAnonymousOperationName());
    BindingInfo bi = rmep.getBindingInfo(protocol);
    BindingOperationInfo boi = bi.getOperation(oi);

    newex.put(BindingInfo.class, bi);
    newex.put(BindingOperationInfo.class, boi);

    msg.setExchange(newex);
    newex.setOutMessage(msg);
}
 
Example 7
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBindingOperationInfo() throws Exception {
    setUpBasic();
    BindingInfo bindingInfo = null;
    bindingInfo = serviceInfo.getBindings().iterator().next();
    Collection<BindingOperationInfo> bindingOperationInfos = bindingInfo.getOperations();
    assertNotNull(bindingOperationInfos);
    assertEquals(bindingOperationInfos.size(), 4);
    LOG.info("the binding operation is " + bindingOperationInfos.iterator().next().getName());

    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
    BindingOperationInfo sayHi = bindingInfo.getOperation(name);
    assertNotNull(sayHi);
    assertEquals(sayHi.getName(), name);

    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMe");
    BindingOperationInfo greetMe = bindingInfo.getOperation(name);
    assertNotNull(greetMe);
    assertEquals(greetMe.getName(), name);

    name = new QName(serviceInfo.getName().getNamespaceURI(), "greetMeOneWay");
    BindingOperationInfo greetMeOneWay = bindingInfo.getOperation(name);
    assertNotNull(greetMeOneWay);
    assertEquals(greetMeOneWay.getName(), name);

    name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
    BindingOperationInfo pingMe = bindingInfo.getOperation(name);
    assertNotNull(pingMe);
    assertEquals(pingMe.getName(), name);
    control.verify();
}
 
Example 8
Source File: RPCInInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();
    ServiceInfo si = getMockedServiceModel(this.getClass()
                                           .getResource("/wsdl_soap/hello_world_rpc_lit.wsdl")
            .toString());
    BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
    BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
    boi.getOperationInfo().getInput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
    boi.getOperationInfo().getInput().getMessagePartByIndex(0).setIndex(1);
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setTypeClass(MyComplexStruct.class);
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
    soapMessage.getExchange().put(BindingOperationInfo.class, boi);

    control.reset();
    Service service = control.createMock(Service.class);
    JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
    service.getDataBinding();
    EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
    service.getServiceInfos();
    List<ServiceInfo> list = Arrays.asList(si);
    EasyMock.expectLastCall().andReturn(list).anyTimes();
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();

    soapMessage.getExchange().put(Service.class, service);
    soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    control.replay();
}
 
Example 9
Source File: ServiceModelUtilTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSchema() throws Exception {
    BindingInfo bindingInfo = null;
    bindingInfo = serviceInfo.getBindings().iterator().next();
    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "inHeader");
    BindingOperationInfo inHeader = bindingInfo.getOperation(name);
    BindingMessageInfo input = inHeader.getInput();
    assertNotNull(input);
    assertEquals(input.getMessageInfo().getName().getLocalPart(), "inHeaderRequest");
    assertEquals(input.getMessageInfo().getName().getNamespaceURI(),
                 "http://org.apache.cxf/headers");
    assertEquals(input.getMessageInfo().getMessageParts().size(), 2);
    assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
    assertEquals(
        input.getMessageInfo().getMessageParts().get(0).getElementQName().getLocalPart(), "inHeader");
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getElementQName().getNamespaceURI(),
                 "http://org.apache.cxf/headers");

    assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
    assertEquals(
        input.getMessageInfo().getMessageParts().get(1).getElementQName().getLocalPart(), "passenger");
    assertEquals(input.getMessageInfo().getMessageParts().get(1).getElementQName().getNamespaceURI(),
                 "http://mycompany.example.com/employees");
    assertTrue(input.getMessageInfo().getMessageParts().get(1).isElement());

    MessagePartInfo messagePartInfo = input.getMessageInfo().getMessageParts().get(0);
    SchemaInfo schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo);
    assertEquals(schemaInfo.getNamespaceURI(), "http://org.apache.cxf/headers");

    messagePartInfo = input.getMessageInfo().getMessageParts().get(1);
    schemaInfo = ServiceModelUtil.getSchema(serviceInfo, messagePartInfo);
    assertEquals(schemaInfo.getNamespaceURI(), "http://mycompany.example.com/employees");
}
 
Example 10
Source File: RPCOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    super.setUp();
    ServiceInfo si = getMockedServiceModel(this.getClass()
                                           .getResource("/wsdl_soap/hello_world_rpc_lit.wsdl")
            .toString());
    BindingInfo bi = si.getBinding(new QName(TNS, "Greeter_SOAPBinding_RPCLit"));
    BindingOperationInfo boi = bi.getOperation(new QName(TNS, OPNAME));
    boi.getOperationInfo().getOutput().getMessagePartByIndex(0).setIndex(0);
    soapMessage.getExchange().put(BindingOperationInfo.class, boi);

    control.reset();
    Service service = control.createMock(Service.class);
    EasyMock.expect(service.isEmpty()).andReturn(true).anyTimes();
    JAXBDataBinding dataBinding = new JAXBDataBinding(MyComplexStruct.class);
    service.getDataBinding();
    EasyMock.expectLastCall().andReturn(dataBinding).anyTimes();
    service.getServiceInfos();
    List<ServiceInfo> list = Arrays.asList(si);
    EasyMock.expectLastCall().andReturn(list).anyTimes();

    soapMessage.getExchange().put(Service.class, service);
    soapMessage.getExchange().put(Message.SCHEMA_VALIDATION_ENABLED, Boolean.FALSE);
    control.replay();

    MyComplexStruct mcs = new MyComplexStruct();
    mcs.setElem1("elem1");
    mcs.setElem2("elem2");
    mcs.setElem3(45);
    MessageContentsList param = new MessageContentsList();
    param.add(mcs);
    soapMessage.setContent(List.class, param);
}
 
Example 11
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testBareOutSingle() throws Exception {

    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add(myComplexStruct);

    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"),
                    MyComplexStructType.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "sendReceiveData"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareMyComplexStructTypeQName.getLocalPart(), dxr.getLocalName());
    StaxUtils.toNextElement(dxr);
    StaxUtils.toNextText(dxr);
    assertEquals(myComplexStruct.getElem1(), dxr.getText());
}
 
Example 12
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected NVList prepareArguments(CorbaMessage corbaMsg,
                                  InterfaceInfo info,
                                  OperationType opType,
                                  QName opQName,
                                  CorbaTypeMap typeMap,
                                  CorbaDestination destination,
                                  ServiceInfo service) {
    BindingInfo bInfo = destination.getBindingInfo();
    EndpointInfo eptInfo = destination.getEndPointInfo();
    BindingOperationInfo bOpInfo = bInfo.getOperation(opQName);
    OperationInfo opInfo = bOpInfo.getOperationInfo();
    Exchange exg = corbaMsg.getExchange();
    exg.put(BindingInfo.class, bInfo);
    exg.put(InterfaceInfo.class, info);
    exg.put(EndpointInfo.class, eptInfo);
    exg.put(EndpointReferenceType.class, destination.getAddress());
    exg.put(ServiceInfo.class, service);
    exg.put(BindingOperationInfo.class, bOpInfo);
    exg.put(OperationInfo.class, opInfo);
    exg.put(MessageInfo.class, opInfo.getInput());
    exg.put(String.class, opQName.getLocalPart());
    exg.setInMessage(corbaMsg);

    corbaMsg.put(MessageInfo.class, opInfo.getInput());

    List<ParamType> paramTypes = opType.getParam();
    CorbaStreamable[] arguments = new CorbaStreamable[paramTypes.size()];
    return prepareDIIArgsList(corbaMsg, bOpInfo,
                              arguments, paramTypes,
                              typeMap,
                              exg.get(ORB.class), service);
}
 
Example 13
Source File: SoapClient.java    From jea with Apache License 2.0 5 votes vote down vote up
private QName getQName(Endpoint endpoint, String methodName){
       BindingInfo bindingInfo = endpoint.getEndpointInfo().getBinding();
       QName opName = new QName(endpoint.getService().getName().getNamespaceURI(), methodName);
       
       if (bindingInfo.getOperation(opName) == null) {
           for (BindingOperationInfo operationInfo : bindingInfo.getOperations()) {
               if (methodName.equals(operationInfo.getName().getLocalPart())) {
                   opName = operationInfo.getName();
                   break;
               }
           }
       }
       return opName;
}
 
Example 14
Source File: XMLMessageOutInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testBareOutMultiWithRoot() throws Exception {

    MyComplexStructType myComplexStruct = new MyComplexStructType();
    myComplexStruct.setElem1("elem1");
    myComplexStruct.setElem2("elem2");
    myComplexStruct.setElem3(45);
    params.add("tli");
    params.add(myComplexStruct);

    common("/wsdl/hello_world_xml_bare.wsdl", new QName(bareNs, "XMLPort"),
                    MyComplexStructType.class);

    BindingInfo bi = super.serviceInfo.getBinding(new QName(bareNs, "Greeter_XMLBinding"));
    BindingOperationInfo boi = bi.getOperation(new QName(bareNs, "testMultiParamPart"));
    xmlMessage.getExchange().put(BindingOperationInfo.class, boi);

    out.handleMessage(xmlMessage);

    XMLStreamReader reader = getXMLReader();
    DepthXMLStreamReader dxr = new DepthXMLStreamReader(reader);
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareNs, dxr.getNamespaceURI());
    assertEquals("multiParamRootReq", dxr.getLocalName());
    StaxUtils.nextEvent(dxr);
    StaxUtils.toNextElement(dxr);

    assertEquals(bareRequestTypeQName, dxr.getName());
    StaxUtils.nextEvent(dxr);
    if (StaxUtils.toNextText(dxr)) {
        assertEquals("tli", dxr.getText());
    }

    boolean foundRequest = false;
    while (true) {
        StaxUtils.nextEvent(dxr);
        StaxUtils.toNextElement(dxr);
        QName requestType = new QName(dxr.getNamespaceURI(), dxr.getLocalName());
        if (requestType.equals(bareMyComplexStructQName)) {
            foundRequest = true;
            break;
        }
    }
    assertTrue("found request type", foundRequest);
}
 
Example 15
Source File: AbstractWSDLBindingFactory.java    From cxf with Apache License 2.0 4 votes vote down vote up
protected BindingInfo initializeBindingInfo(ServiceInfo service, Binding binding, BindingInfo bi) {
    bi.setName(binding.getQName());
    copyExtensors(bi, binding, null);

    for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
        String inName = null;
        String outName = null;
        if (bop.getBindingInput() != null) {
            inName = bop.getBindingInput().getName();
        }
        if (bop.getBindingOutput() != null) {
            outName = bop.getBindingOutput().getName();
        }
        String portTypeNs = binding.getPortType().getQName().getNamespaceURI();
        QName opName = new QName(portTypeNs,
                                 bop.getName());
        BindingOperationInfo bop2 = bi.getOperation(opName);
        if (bop2 == null) {
            bop2 = bi.buildOperation(opName, inName, outName);
            if (bop2 != null) {
                bi.addOperation(bop2);
            }
        }
        if (bop2 != null) {
            copyExtensors(bop2, bop, bop2);
            if (bop.getBindingInput() != null) {
                copyExtensors(bop2.getInput(), bop.getBindingInput(), bop2);
            }
            if (bop.getBindingOutput() != null) {
                copyExtensors(bop2.getOutput(), bop.getBindingOutput(), bop2);
            }
            for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
                if (StringUtils.isEmpty(f.getName())) {
                    throw new IllegalArgumentException("wsdl:fault and soap:fault elements"
                                                       + " must have a name attribute.");
                }
                copyExtensors(bop2.getFault(new QName(service.getTargetNamespace(), f.getName())),
                              bop.getBindingFault(f.getName()), bop2);
            }
        }
    }
    return bi;
}
 
Example 16
Source File: Proxy.java    From cxf with Apache License 2.0 4 votes vote down vote up
Object invoke(OperationInfo oi, ProtocolVariation protocol,
              Object[] params, Map<String, Object> context, 
              Exchange exchange,
              Level exceptionLevel) throws RMException {

    if (LOG.isLoggable(Level.INFO)) {
        LOG.log(Level.INFO, "Sending out-of-band RM protocol message {0}.",
                oi == null ? null : oi.getName());
    }

    RMManager manager = reliableEndpoint.getManager();
    Bus bus = manager.getBus();
    Endpoint endpoint = reliableEndpoint.getEndpoint(protocol);
    BindingInfo bi = reliableEndpoint.getBindingInfo(protocol);
    Conduit c = reliableEndpoint.getConduit();
    Client client = null;
    if (params.length > 0 && params[0] instanceof DestinationSequence) {
        EndpointReferenceType acksTo = ((DestinationSequence)params[0]).getAcksTo();
        String acksAddress = acksTo.getAddress().getValue();
        AttributedURIType attrURIType = new AttributedURIType();
        attrURIType.setValue(acksAddress);
        EndpointReferenceType acks = new EndpointReferenceType();
        acks.setAddress(attrURIType);
        client = createClient(bus, endpoint, protocol, c, acks);
        params = new Object[] {};
    } else {
        EndpointReferenceType replyTo = reliableEndpoint.getReplyTo();
        client = createClient(bus, endpoint, protocol, c, replyTo);
    }

    BindingOperationInfo boi = bi.getOperation(oi);
    try {
        if (context != null) {
            client.getRequestContext().putAll(context);
        }
        Object[] result = client.invoke(boi, params, context, exchange);
        if (result != null && result.length > 0) {
            return result[0];
        }

    } catch (Exception ex) {
        org.apache.cxf.common.i18n.Message msg =
            new org.apache.cxf.common.i18n.Message("SEND_PROTOCOL_MSG_FAILED_EXC", LOG,
                                                   oi == null ? null : oi.getName());
        LOG.log(exceptionLevel, msg.toString(), ex);
        throw new RMException(msg, ex);
    }
    return null;
}
 
Example 17
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testBindingMessageInfo() throws Exception {
    setUpBasic();
    BindingInfo bindingInfo = null;
    bindingInfo = serviceInfo.getBindings().iterator().next();

    QName name = new QName(serviceInfo.getName().getNamespaceURI(), "sayHi");
    BindingOperationInfo sayHi = bindingInfo.getOperation(name);
    BindingMessageInfo input = sayHi.getInput();
    assertNotNull(input);
    assertEquals(input.getMessageInfo().getName().getLocalPart(), "sayHiRequest");
    assertEquals(input.getMessageInfo().getName().getNamespaceURI(),
            "http://apache.org/hello_world_soap_http");
    assertEquals(input.getMessageInfo().getMessageParts().size(), 1);
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(), "in");
    assertEquals(input.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(),
            "http://apache.org/hello_world_soap_http");
    assertTrue(input.getMessageInfo().getMessageParts().get(0).isElement());
    QName elementName = input.getMessageInfo().getMessageParts().get(0).getElementQName();
    assertEquals(elementName.getLocalPart(), "sayHi");
    assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");

    BindingMessageInfo output = sayHi.getOutput();
    assertNotNull(output);
    assertEquals(output.getMessageInfo().getName().getLocalPart(), "sayHiResponse");
    assertEquals(output.getMessageInfo().getName().getNamespaceURI(),
            "http://apache.org/hello_world_soap_http");
    assertEquals(output.getMessageInfo().getMessageParts().size(), 1);
    assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getLocalPart(), "out");
    assertEquals(output.getMessageInfo().getMessageParts().get(0).getName().getNamespaceURI(),
            "http://apache.org/hello_world_soap_http");
    assertTrue(output.getMessageInfo().getMessageParts().get(0).isElement());
    elementName = output.getMessageInfo().getMessageParts().get(0).getElementQName();
    assertEquals(elementName.getLocalPart(), "sayHiResponse");
    assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");

    assertTrue(sayHi.getFaults().isEmpty());

    name = new QName(serviceInfo.getName().getNamespaceURI(), "pingMe");
    BindingOperationInfo pingMe = bindingInfo.getOperation(name);
    assertNotNull(pingMe);
    assertEquals(1, pingMe.getFaults().size());
    BindingFaultInfo fault = pingMe.getFaults().iterator().next();

    assertNotNull(fault);
    assertEquals(fault.getFaultInfo().getName().getLocalPart(), "pingMeFault");
    assertEquals(fault.getFaultInfo().getName().getNamespaceURI(),
            "http://apache.org/hello_world_soap_http");
    assertEquals(fault.getFaultInfo().getMessageParts().size(), 1);
    assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getLocalPart(), "faultDetail");
    assertEquals(fault.getFaultInfo().getMessageParts().get(0).getName().getNamespaceURI(),
            "http://apache.org/hello_world_soap_http");
    assertTrue(fault.getFaultInfo().getMessageParts().get(0).isElement());
    elementName = fault.getFaultInfo().getMessageParts().get(0).getElementQName();
    assertEquals(elementName.getLocalPart(), "faultDetail");
    assertEquals(elementName.getNamespaceURI(), "http://apache.org/hello_world_soap_http/types");
    control.verify();
}
 
Example 18
Source File: WSDLServiceBuilderTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Test
public void testExtensions() throws Exception {
    setUpWSDL("hello_world_ext.wsdl", 0);

    String ns = "http://apache.org/hello_world_soap_http";
    QName pingMeOpName = new QName(ns, "pingMe");
    QName greetMeOpName = new QName(ns, "greetMe");
    QName faultName = new QName(ns, "pingMeFault");

    // portType extensions

    InterfaceInfo ii = serviceInfo.getInterface();
    assertEquals(2, ii.getExtensionAttributes().size());
    assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_BOOLEAN));
    assertNotNull(ii.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, ii.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, ii.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // portType/operation extensions

    OperationInfo oi = ii.getOperation(pingMeOpName);
    assertPortTypeOperationExtensions(oi, true);
    assertPortTypeOperationExtensions(ii.getOperation(greetMeOpName), false);

    // portType/operation/[input|output|fault] extensions

    assertPortTypeOperationMessageExtensions(oi, true, true, faultName);
    assertPortTypeOperationMessageExtensions(ii.getOperation(greetMeOpName), false, true, null);

    // service extensions

    assertEquals(1, serviceInfo.getExtensionAttributes().size());
    assertNotNull(serviceInfo.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, serviceInfo.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM,
        serviceInfo.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // service/port extensions

    EndpointInfo ei = serviceInfo.getEndpoints().iterator().next();
    assertEquals(1, ei.getExtensionAttributes().size());
    assertNotNull(ei.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, ei.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, ei.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // binding extensions

    BindingInfo bi = ei.getBinding();
    // REVISIT: bug in wsdl4j?
    // getExtensionAttributes on binding element returns an empty map
    // assertEquals(1, bi.getExtensionAttributes().size());
    // assertNotNull(bi.getExtensionAttribute(EXTENSION_ATTR_STRING));
    assertEquals(1, bi.getExtensors(UnknownExtensibilityElement.class).size());
    assertEquals(EXTENSION_ELEM, bi.getExtensor(UnknownExtensibilityElement.class).getElementType());

    // binding/operation extensions

    BindingOperationInfo boi = bi.getOperation(pingMeOpName);
    assertBindingOperationExtensions(boi, true);
    assertBindingOperationExtensions(bi.getOperation(greetMeOpName), false);

    // binding/operation/[input|output|fault] extensions

    assertBindingOperationMessageExtensions(boi, true, true, faultName);
    assertBindingOperationMessageExtensions(bi.getOperation(greetMeOpName), false, true, null);
    control.verify();

}