Spring jar

Service serviceModel = new ObjectServiceFactory().create(ExchangeService.class);
String serviceURL = "http://[ip]:[port]/[yourProjectName]/services/ExchangeService";//相应需要修改
ExchangeService service = null;
try{
service = (ExchangeService)new XFireProxyFactory().create(serviceModel, serviceURL);
}catch(Exception e){
throw new RuntimeException(e);
}
return service.RMB2Dollar(RMB);


try{
String wsdl = "http://[ip]:[port]/[yourProjectName]/services/ExchangeService?wsdl";
URL url = new URL(wsdl);
HttpURLConnection httpConnection = (HttpURLConnection)url.openConnection();
httpConnection.connect();
Client client = new Client(httpConnection.getInputStream(),null);
Object []results = client.invoke("RMB2Dollar", new Object[]{RMB});
return (Double)results[0];
}catch(Exception e){
throw new RuntimeException(e);
}

xfire 1.2.6 API帮助文档.rar http://d.download.csdn.net/down/539573/lip8654

 

1,简单的方式

Service serviceModel  =   new  ObjectServiceFactory().create(YourService. class );
YourService service 
=  (YourService)
    
new  XFireProxyFactory().create(serviceModel,  " http://your/remote/url " );

2,JSR 181注释的方式

Service serviceModel  =   new  AnnotationServiceFactory().create(YourService. class );
YourService client 
=  (YourService)
    
new  XFireProxyFactory().create(serviceModel,  " http://your/remote/url " );

3,混合方式

Service serviceModel  =
  
new  AnnotationServiceFactory(
   
new  Jsr181WebAnnotations(),
   XFireFactory.newInstance().getXFire().getTransportManager(),
   
new  AegisBindingProvider( new  JaxbTypeRegistry())).create(YourService. class );


Client client = new Client(

                          new URL("http://localhost:8080/xfiretest/services/TestService?wsdl));
        Object[] results 
= client.invoke("sayHello"new Object[] "Firends" });
        System.out.println(results[
0]);

你可能感兴趣的:(spring,.net)