Package javax.xml.ws.addressing.soap

Examples of javax.xml.ws.addressing.soap.SOAPAddressingProperties


  protected boolean handleInbound(MessageContext msgContext)
  {
    if(log.isDebugEnabled()) log.debug("handleInbound");

    SOAPAddressingProperties addrProps = (SOAPAddressingProperties)ADDR_BUILDER.newAddressingProperties();
    SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
    CommonMessageContext commonMsgContext = (CommonMessageContext)msgContext;
    ServerEndpointMetaData serverMetaData = (ServerEndpointMetaData)commonMsgContext.getEndpointMetaData();
    AddressingFeature addrFeature = serverMetaData.getFeature(AddressingFeature.class);
        if (addrFeature != null && addrFeature.isRequired())
        {
           try
           {
               soapMessage.setProperty("isRequired", true);
           }
           catch (Exception e)
           {
              //ignore
           }
          
        }
        addrProps.readHeaders(soapMessage);
        msgContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND, addrProps);
        msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND, Scope.APPLICATION);
        msgContext.put(MessageContext.REFERENCE_PARAMETERS, convertToElementList(addrProps.getReferenceParameters().getElements()));
        msgContext.setScope(MessageContext.REFERENCE_PARAMETERS, Scope.APPLICATION);
       
        //check if soap action matches wsa action
        String[] soapActions = commonMsgContext.getMessageAbstraction().getMimeHeaders().getHeader("SOAPAction");
        if (soapActions != null && soapActions.length > 0)
        {
         String soapAction = soapActions[0];
         if (!soapAction.equals("\"\""&& addrProps.getAction() != null)               
         {
            String wsaAction = addrProps.getAction().getURI().toString();
            // R1109 The value of the SOAPAction HTTP header field in a HTTP request MESSAGE MUST be a quoted string.
            if (!soapAction.equals(wsaAction) && !soapAction.equals("\"" + wsaAction + "\""))
            {
               try
               {
                  SOAPFault fault = new SOAPFaultImpl();
                  fault.setFaultCode(new QName(ADDR_CONSTANTS.getNamespaceURI(), "ActionMismatch"));
                  fault.setFaultString("Mismatch between soap action:" + soapAction + " and wsa action:\""
                        + addrProps.getAction().getURI() + "\"");
                  Detail detail = fault.addDetail();
                  detail.addDetailEntry(new QName(ADDR_CONSTANTS.getNamespaceURI(), "ProblemAction"));
                  throw new SOAPFaultException(fault);
               }
               catch (SOAPException e)
View Full Code Here


  private void handleResponseOrFault(MessageContext msgContext, boolean isFault)
  {
    SOAPAddressingBuilder builder = (SOAPAddressingBuilder)SOAPAddressingBuilder.getAddressingBuilder();
    SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();

    SOAPAddressingProperties inProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND);
    SOAPAddressingProperties outProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND);

    if (outProps == null)
    {
      // create new response properties
      outProps = (SOAPAddressingProperties)builder.newAddressingProperties();
      msgContext.put(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, outProps);
      msgContext.setScope(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
    }
      
    if (inProps != null)
    outProps.initializeAsReply(inProps, isFault);

    try
    {
      // supply the response action

      OperationMetaData opMetaData = ((CommonMessageContext)msgContext).getOperationMetaData();

      if (!isFault && !opMetaData.isOneWay())
      {

        AddressingOpMetaExt addrExt = (AddressingOpMetaExt)opMetaData.getExtension(ADDR_CONSTANTS.getNamespaceURI());
        if (addrExt != null)
        {
            outProps.setAction(ADDR_BUILDER.newURI(addrExt.getOutboundAction()));
        }
        else
        {
          log.warn("Unable to resolve replyAction for " + opMetaData.getQName());
        }

      }
      else if (isFault)        
      {
         AddressingOpMetaExt addrExt = (AddressingOpMetaExt)opMetaData.getExtension(ADDR_CONSTANTS.getNamespaceURI());
               if (addrExt != null && msgContext.get("Exception") != null
                     && addrExt.getFaultActions() != null && addrExt.getFaultActions().length > 0)
               {
                  Exception ex = (Exception)msgContext.get("Exception");
                  for(FaultAction faultAction  : addrExt.getFaultActions())
                  {
                     if (faultAction.className().getName().equals(ex.getClass().getName()))
                     {
                        outProps.setAction(ADDR_BUILDER.newURI(faultAction.value()));
                        break;
                     }
                  }                                          
               }
               if (outProps.getAction() == null) {
                  outProps.setAction(ADDR_BUILDER.newURI(ADDR_CONSTANTS.getDefaultFaultAction()));
               }       
      }

    }
    catch (URISyntaxException e)
    {
      log.error("Error setting response action", e);
    }

    outProps.writeHeaders(soapMessage);
  }
View Full Code Here

  protected boolean handleOutbound(MessageContext msgContext)
  {
    log.debug("handleOutbound");

      SOAPAddressingProperties addrProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES);
      if (addrProps != null)
      {
         msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, addrProps);
         msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
      }
     
      addrProps = (SOAPAddressingProperties)msgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
      if (addrProps == null)
      {
         // supply default addressing properties
         addrProps = (SOAPAddressingPropertiesImpl)ADDR_BUILDER.newAddressingProperties();
         msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, addrProps);
         msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, Scope.APPLICATION);
      }
     
      if (addrProps.getAction() == null)
      {
         try
         {
            OperationMetaData opMetaData = ((CommonMessageContext)msgContext).getOperationMetaData();
            if (msgContext.get(BindingProvider.SOAPACTION_URI_PROPERTY) != null)
            {
              addrProps.setAction(ADDR_BUILDER.newURI(msgContext.get(BindingProvider.SOAPACTION_URI_PROPERTY).toString()));
            }
            else
            {
                addrProps.setAction(ADDR_BUILDER.newURI(opMetaData.getJavaName()));
            }
         }
         catch (URISyntaxException ex)
         {
            // ignore
         }
      }
     
      //Add this optional messageID
      if (addrProps.getMessageID()== null)
      {
         addrProps.setMessageID(AddressingClientUtil.createMessageID());
      }
     
    SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
    addrProps.writeHeaders(soapMessage);

    return true;
  }
View Full Code Here

    {
      SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
      if (soapMessage.getSOAPPart().getEnvelope() != null)
      {
        SOAPAddressingBuilder builder = (SOAPAddressingBuilder)SOAPAddressingBuilder.getAddressingBuilder();
        SOAPAddressingProperties addrProps = (SOAPAddressingProperties)builder.newAddressingProperties();
            CommonMessageContext commonMsgContext = (CommonMessageContext)msgContext;
            ClientEndpointMetaData serverMetaData = (ClientEndpointMetaData)commonMsgContext.getEndpointMetaData();
            AddressingFeature addrFeature = serverMetaData.getFeature(AddressingFeature.class);
            if (addrFeature != null && addrFeature.isRequired())
            {
               try
               {
                   soapMessage.setProperty("isRequired", true);
               }
               catch (Exception e)
               {
                  //ignore
               }
              
            }
            addrProps.readHeaders(soapMessage);       
            msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, addrProps);
                msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, Scope.APPLICATION);
                msgContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND, addrProps);
                msgContext.setScope(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_INBOUND, Scope.APPLICATION);
                msgContext.put(MessageContext.REFERENCE_PARAMETERS, convertToElementList(addrProps.getReferenceParameters().getElements()));
                msgContext.setScope(MessageContext.REFERENCE_PARAMETERS, Scope.APPLICATION);
             }
    }
    catch (SOAPException ex)
    {
View Full Code Here

      setRequestProperties((BindingProvider)echoPort, requestProps);

      // invoke service
      echoPort.echo("Message 1230");

      SOAPAddressingProperties responseProperties = (SOAPAddressingProperties)
          getResponseProperties((BindingProvider)echoPort);

      forceReset();

      Relationship rel = responseProperties.getRelatesTo()[0];
      assertEquals(rel.getID().toString(), requestProps.getMessageID().getURI().toString());

   }
View Full Code Here

      setRequestProperties((BindingProvider)echoPort, requestProps);

      // invoke service
      echoPort.echo("Message 1231");

      SOAPAddressingProperties responseProperties = (SOAPAddressingProperties)
          getResponseProperties((BindingProvider)echoPort);
      forceReset();

      Relationship rel = responseProperties.getRelatesTo()[0];
      assertEquals(rel.getID().toString(), requestProps.getMessageID().getURI().toString());
      assertTrue(null == responseProperties.getReplyTo());

   }
View Full Code Here

      setRequestProperties((BindingProvider)echoPort, requestProps);

      // invoke service
      echoPort.echo("Message 1232");

      SOAPAddressingProperties responseProperties = (SOAPAddressingProperties)
          getResponseProperties((BindingProvider)echoPort);

      forceReset();

      Relationship rel = responseProperties.getRelatesTo()[0];
      assertEquals(rel.getID().toString(), requestProps.getMessageID().getURI().toString());
      assertTrue(null == responseProperties.getReplyTo());
      List<Object> returnParameters = responseProperties.getReferenceParameters().getElements();
      assertFalse("Reference parameter is missing", returnParameters.isEmpty());

   }
View Full Code Here

      {
         boolean isSoapFault = (e.getCause() instanceof SOAPFaultException);
         if(!isSoapFault) throw e;
      }

      SOAPAddressingProperties responseProperties = (SOAPAddressingProperties)
          getResponseProperties((BindingProvider)echoPort);

      forceReset();

      Relationship rel = responseProperties.getRelatesTo()[0];
      assertEquals(rel.getID().toString(), requestProps.getMessageID().getURI().toString());
      assertTrue(null == responseProperties.getReplyTo());
      List<Object> returnParameters = responseProperties.getReferenceParameters().getElements();
      assertFalse("Reference parameter is missing", returnParameters.isEmpty());
   }
View Full Code Here

      {
         boolean isSoapFault = (e.getCause() instanceof SOAPFaultException);
         if(!isSoapFault) throw e;
      }

      SOAPAddressingProperties responseProperties = (SOAPAddressingProperties)
          getResponseProperties((BindingProvider)echoPort);

      forceReset();

      Relationship rel = responseProperties.getRelatesTo()[0];
      assertEquals(rel.getID().toString(), requestProps.getMessageID().getURI().toString());
      assertTrue(null == responseProperties.getReplyTo());
      List<Object> returnParameters = responseProperties.getReferenceParameters().getElements();
      assertFalse("Reference parameter is missing", returnParameters.isEmpty());
   }
View Full Code Here

      log.info("enter handleRequest");

      try
      {
         AddressingBuilder builder = SOAPAddressingBuilder.getAddressingBuilder();
         SOAPAddressingProperties outProps = (SOAPAddressingProperties)builder.newAddressingProperties();
         outProps.setTo(builder.newURI("http://" + getServerHost() + ":8080/jaxrpc-samples-wsaddr-hello"));
         outProps.setAction(builder.newURI("http://org.jboss.ws/jaxrpc/samples/wsaddr/replyto/sayHello"));
         EndpointReference rp = builder.newEndpointReference(new URI("http://" + getServerHost() + ":8080/jaxrpc-samples-wsaddr-replyto"));
         outProps.setReplyTo(rp);
         outProps.setMessageID(builder.newURI("123456"));
         context.setProperty(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND, outProps);
      }
      catch(URISyntaxException e)
      {
         e.printStackTrace();
View Full Code Here

TOP

Related Classes of javax.xml.ws.addressing.soap.SOAPAddressingProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.