1 Reply Latest reply on Mar 12, 2009 12:33 PM by Nico Vassallo

    How can I print to log file input soap request and response?

    Nico Vassallo Newbie

      How can I print to log file input soap request and response?

      For example:

      @WebService( )
      public class ARE_GetBanner {
      @WebMethod(operationName = "GetBanner")
      public GetBannerOutputData GetBanner(@WebParam(name = "inputdata")
      org.isc.are.ws.GetBannerInputData inputdata) {

      ????log soap request????
      --- my flow logic ---
      ????log soap response????

      }

      Who have any idea?
      Thanks in advanced.

        • 1. Re: How can I print to log file input soap request and respo
          Nico Vassallo Newbie

          Solution for:
          server: jbossas 4.2.1.GA
          server library: jbossws-1.2
          source library: jbossws-src-1.2.1.GA in http://www.jboss.org/jbossws/downloads/
          jar_path: jboss/server/default/deploy/jbossws.sar/jbossws-core.jar
          package: org.jboss.ws.core.jaxws
          class: JAXBDeserializer
          method: public Object deserialize(QName xmlName, QName xmlType, Source xmlFragment, SerializationContext serContext) throws BindingException

          Must be add the code below:
          String sourceString = sourceToString(xmlFragment);
          if(log.isDebugEnabled()) log.debug("InputSourceString: "+sourceString);

          below the method upgraded:

          public Object deserialize(QName xmlName, QName xmlType, Source xmlFragment, SerializationContext serContext) throws BindingException
          {
          if(log.isDebugEnabled()) log.debug("deserialize: [xmlName=" + xmlName + ",xmlType=" + xmlType + "]");


          Object value = null;
          try
          {
          String sourceString = sourceToString(xmlFragment);
          if(log.isDebugEnabled()) log.debug("InputSourceString: "+sourceString);


          Class[] javaTypes = (Class[])serContext.getProperty(SerializationContextJAXWS.CONTEXT_TYPES);

          TypeMappingImpl typeMapping = serContext.getTypeMapping();
          Class javaType = typeMapping.getJavaType(xmlType); // es. javaType: class org.isc.are.ws.jaxws.GetBanner

          JAXBContext jaxbContext = getJAXBContext(javaTypes);

          Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

          //SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
          //Source schemaSource = new StreamSource(new File("/home/jboss/jboss/testdatasource/ARE_GetBannerService.xsd"));
          //Schema schema = schemaFactory.newSchema(schemaSource);
          //unmarshaller.setSchema(schema);

          unmarshaller.setAttachmentUnmarshaller( new AttachmentUnmarshallerImpl());
          JAXBElement jbe = unmarshaller.unmarshal(xmlFragment, javaType);
          value = jbe.getValue();

          if(log.isDebugEnabled()) log.debug("deserialized: " + (value != null ? value.getClass().getName() : null)); //deserialized: org.isc.are.ws.jaxws.GetBanner
          }
          catch (Exception ex)
          {
          log.error("error during deserialize.", ex);
          handleUnmarshallException(ex);
          }
          return value;
          }