1 29 30 package com.caucho.soap.service; 31 32 import javax.xml.namespace.QName ; 33 import javax.xml.ws.Service; 34 import java.lang.reflect.InvocationHandler ; 35 import java.lang.reflect.Proxy ; 36 37 public class ServiceImpl extends Service { 38 39 private QName _serviceName; 40 41 public ServiceImpl(QName serviceName) 42 { 43 super(null, serviceName); 44 this._serviceName = serviceName; 45 } 46 47 public <T> T getPort(Class <T> sei) 48 { 49 return getPort(_serviceName, sei); 50 } 51 52 public <T> T getPort(QName portName, Class <T> sei) 53 { 54 String url = portName.getNamespaceURI(); 55 try { 56 InvocationHandler ih = 57 new ServiceImplInvocationHandler(sei, url); 58 Class proxyClass = 59 Proxy.getProxyClass(sei.getClassLoader(), 60 new Class [] { sei }); 61 T t = (T) proxyClass 62 .getConstructor(new Class [] { InvocationHandler .class }) 63 .newInstance(new Object [] { ih }); 64 65 return t; 66 } catch (Exception e) { 67 throw new RuntimeException (e); 68 } 69 } 70 } 71 72 | Popular Tags |