现在我们来看xfire的客户端调用,有两种方式:
一、通过服务端提供的接口类进行调用。
Java代码
- package
com.wujianjun.xfire.client; -
-
import
java.net.MalformedURLException; -
import
java.util.List; -
-
import
org.codehaus.xfire.XFire; -
import
org.codehaus.xfire.XFireFactory; -
import
org.codehaus.xfire.client.XFireProxyFactory; -
import
org.codehaus.xfire.service.Service; -
import
org.codehaus.xfire.service.binding.ObjectServiceFactory; -
-
import
com.wujianjun.xfire.domain.Person; -
import
com.wujianjun.xfire.spring.IPersonService; -
-
public
class PojoInvokeClient { -
-
static void main(String[] args) { -
Service serviceModel = ObjectServiceFactory().create(IPersonService. class); -
-
XFire xfire = XFireFactory.newInstance().getXFire(); -
XFireProxyFactory factory = XFireProxyFactory(xfire); -
String serviceUrl = -
-
IPersonService client = -
{ -
client = (IPersonService) factory.create(serviceModel, serviceUrl); -
} (MalformedURLException e) { -
System.out.println( call +webservice has exception: " e.toString()); -
} -
-
String result1 =client.sayHello( -
-
} - }
Java代码
- package
com.wujianjun.xfire.client; -
-
import
java.net.MalformedURLException; -
import
java.net.URL; -
-
import
org.codehaus.xfire.client.Client; -
-
public
class UrlInvokeClient { -
-
static void main(String[] args) { -
Client client = -
{ -
client = Client( newURL( "http://127.0.0.1:8080/xfire/PersonService.ws?wsdl")); -
Object[] result1 = client.invoke( new Object[] "张三"});{ -
System.out.println(result1[ -
} (MalformedURLException e) { -
e.printstacktrace(); -
} (Exception e) { -
e.printstacktrace(); -
} -
} - }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。