Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.arjuna.webservices11.wsaddr;
 
 
helper class to allow transformation of W3CEndpointreference instances to internal types which are not opaque
public class EndpointHelper
    public static <T extends EndpointReference> T transform(Class<T> clazzEndpointReference epr)
    {
       assert epr != null;
       if (clazz.isAssignableFrom(W3CEndpointReference.class))
       {
          if (epr instanceof W3CEndpointReference)
          {
             return (T)epr;
          }
          else if (epr instanceof NativeEndpointReference)
          {
             return (T)W3CEndpointReference.readFrom(getSourceFromEndpointReference(epr));
          }
          else
          {
             throw new WebServiceException("Unsupported EndpointReference: " + epr);
          }
       }
       else if (clazz.isAssignableFrom(NativeEndpointReference.class))
       {
          return (T)NativeEndpointReference.readFrom(getSourceFromEndpointReference(epr));
       }
       //transformations from different types of EndpointReference could be supported in future...
       throw new WebServiceException("EndpointReference of type " + clazz + " not supported.");
    }
    {
       ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
       StreamResult result = new StreamResult(outputStream);
       epr.writeTo(result);
       return new StreamSource(new ByteArrayInputStream(outputStream.toByteArray()));
    }
New to GrepCode? Check out our FAQ X