private OperationDescription expectedOperationDescription(
     MessageContext requestMC, String operationName) {
   EndpointDescription endpointDescription = requestMC.getEndpointDescription();
   EndpointInterfaceDescription endpointInterfaceDescription =
       endpointDescription.getEndpointInterfaceDescription();
   QName operationQName = new QName("http://org/apache/axis2/jaxws/samples/echo", operationName);
   OperationDescription expectedOperationDescription =
       endpointInterfaceDescription.getOperation(operationQName)[0];
   return expectedOperationDescription;
 }
  public void testSEIBasedEndpoint() {
    ServiceDescription serviceDesc =
        DescriptionFactory.createServiceDescription(SEIBasedEndpoint.class);
    assertNotNull(serviceDesc);
    EndpointDescription endpointDesc =
        serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
    assertNotNull(endpointDesc);
    AxisService axisSvc = endpointDesc.getAxisService();
    assertNotNull(axisSvc);

    EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
    assertNotNull(interfaceDesc);

    // There should be a single OpDesc with a single AxisOperation based on the SEI below
    // But it should not be the special named operation and the special dispatcher should not
    // return null for operation dispatch
    OperationDescription opDescs[] = interfaceDesc.getOperations();
    assertNotNull(opDescs);
    assertEquals(1, opDescs.length);
    AxisOperation axisOperation = opDescs[0].getAxisOperation();
    assertNotNull(axisOperation);
    if (EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME.equals(
        axisOperation.getName().getLocalPart())) {
      fail("Operation has the generic provider name");
    }

    // Now verify that the special dispather doesn't find the special operation
    GenericProviderDispatcher dispatcher = new GenericProviderDispatcher();
    MessageContext messageContext = new MessageContext();
    messageContext.setAxisService(axisSvc);

    try {
      // The dispatcher will not try to resolve an AxisService
      assertNull(dispatcher.findService(messageContext));

      // The dispatcher should find the special AxisOperation
      assertNull(dispatcher.findOperation(axisSvc, messageContext));
    } catch (AxisFault e) {
      fail("Unexpected exception" + e);
    }
  }
  public void testGenericHTTPBindingOperation() {
    // The HTTP binding supports a generic operation for WSDL-less endpoints.
    ServiceDescription serviceDesc =
        DescriptionFactory.createServiceDescription(HTTPBindingProviderImpl.class);
    assertNotNull(serviceDesc);
    EndpointDescription endpointDesc =
        serviceDesc.getEndpointDescriptions_AsCollection().iterator().next();
    assertNotNull(endpointDesc);
    AxisService axisSvc = endpointDesc.getAxisService();
    assertNotNull(axisSvc);

    EndpointInterfaceDescription interfaceDesc = endpointDesc.getEndpointInterfaceDescription();
    assertNotNull(interfaceDesc);

    // There should be a single OpDesc with a single AxisOperation with a specific name
    OperationDescription opDescs[] = interfaceDesc.getOperations();
    assertNotNull(opDescs);
    assertEquals(1, opDescs.length);
    AxisOperation axisOperation = opDescs[0].getAxisOperation();
    assertNotNull(axisOperation);
    assertEquals(
        EndpointInterfaceDescription.JAXWS_NOWSDL_PROVIDER_OPERATION_NAME,
        axisOperation.getName().getLocalPart());

    // Now verify that the special dispather can find this operation
    GenericProviderDispatcher dispatcher = new GenericProviderDispatcher();
    MessageContext messageContext = new MessageContext();
    messageContext.setAxisService(axisSvc);

    try {
      // The dispatcher will not try to resolve an AxisService
      assertNull(dispatcher.findService(messageContext));

      // The dispatcher should find the special AxisOperation
      assertEquals(axisOperation, dispatcher.findOperation(axisSvc, messageContext));
    } catch (AxisFault e) {
      fail("Unexpected exception" + e);
    }
  }
예제 #4
0
  public static void addWSDLProperties(
      MessageContext jaxwsMessageContext, SOAPMessageContext soapMessageContext) {
    OperationDescription op = jaxwsMessageContext.getOperationDescription();

    if (op != null && soapMessageContext != null) {
      setProperty(
          soapMessageContext,
          javax.xml.ws.handler.MessageContext.WSDL_OPERATION,
          op.getName(),
          true);

      EndpointInterfaceDescription eid = op.getEndpointInterfaceDescription();
      if (eid != null) {
        EndpointDescription ed = eid.getEndpointDescription();
        QName portType = eid.getPortType();
        if (portType == null || portType.getLocalPart().length() == 0) {
          if (log.isDebugEnabled()) {
            log.debug(
                "Did not get port type from EndpointInterfaceDescription, attempting to get PortType from EndpointDescription");
          }
        }
        if (ed != null) {
          setProperty(
              soapMessageContext,
              javax.xml.ws.handler.MessageContext.WSDL_PORT,
              ed.getPortQName(),
              true);
        }
        setProperty(
            soapMessageContext, javax.xml.ws.handler.MessageContext.WSDL_INTERFACE, portType, true);
      }
    } else {
      if (log.isDebugEnabled()) {
        log.debug("Unable to read WSDL operation, port and interface properties");
      }
    }
  }