private static QName getOperationNameToUse(MessageContext requestMsgCtx, QName defaultOpName) {
   // We need the qname of the operation being invoked to know which
   // AxisOperation the OperationClient should be based on.
   // Note that the OperationDesc is only set through use of the Proxy. Dispatch
   // clients do not use operations, so the operationDesc will be null.  In this
   // case an anonymous AxisService with anonymous AxisOperations for the supported
   // MEPs will be created; and it is that anonymous operation name which needs to
   // be specified
   QName operationName = null;
   OperationDescription opDesc = requestMsgCtx.getOperationDescription();
   if (opDesc != null && opDesc.getAxisOperation() != null) operationName = opDesc.getName();
   else operationName = defaultOpName;
   return operationName;
 }
  public void testOperationResolution_NoSoapBodyElement() {
    Service service = Service.create(wsdlDocumentLocation, serviceQName);
    Dispatch<String> dispatch =
        service.createDispatch(portQName, String.class, Service.Mode.MESSAGE);
    assertNotNull(dispatch);

    String result = dispatch.invoke(echoBodyContent_NoLocalPart_MESSAGE);
    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext requestMC = ic.getRequestMessageContext();

    // Because there is no soap body to process, the runtime won't be able to determine the
    // operation
    OperationDescription opDesc = requestMC.getOperationDescription();
    assertNull("OpDesc from request MC should be null", opDesc);
  }
  public void testOperationResolution() {
    Service service = Service.create(wsdlDocumentLocation, serviceQName);
    Dispatch<String> dispatch =
        service.createDispatch(portQName, String.class, Service.Mode.PAYLOAD);
    assertNotNull(dispatch);

    String result = dispatch.invoke(echoBodyContent_PAYLOAD);
    TestClientInvocationController testController = getInvocationController();
    InvocationContext ic = testController.getInvocationContext();
    MessageContext requestMC = ic.getRequestMessageContext();

    OperationDescription opDesc = requestMC.getOperationDescription();
    assertNotNull("OpDesc from request MC should not be null", opDesc);
    // Make sure we get the correct Operation Description
    OperationDescription expectedOperationDescription = expectedOperationDescription(requestMC);
    assertSame("Wrong operation description returned", expectedOperationDescription, opDesc);
  }
Ejemplo n.º 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");
      }
    }
  }