首页 > Web开发 > 详细

CXF 调用C#.net的WebService

时间:2014-07-29 21:02:12      阅读:327      评论:0      收藏:0      [点我收藏+]

原文链接:http://hi.baidu.com/pengfeiiw/blog/item/3203e29065aa3a8aa977a4d0.html

1.编写C#.net的WebService

Service.cs

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

[WebService(Namespace = "http://localhost:9000/webservices/")]
public class Service : System.Web.Services.WebService
{
    public Service () {

        //如果使用设计的组件,请取消注释以下行 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    
}

Service.asmx

<%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" class="Service" %>

然后开户服务器(注意开启Terminal Services服务)

2.写java客户端

package demo.hw.client;

import demo.hw.server.HelloWorld;
import java.lang.reflect.Method;
import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;

import org.apache.cxf.frontend.ClientProxyFactoryBean;

public final class Client {

    private Client() {
    }

    public static void main(String args[]) throws Exception {

 DynamicClientFactory dcf = DynamicClientFactory.newInstance();   
   org.apache.cxf.endpoint.Client client = dcf.createClient("http://localhost:1475/ddd/Service.asmx?wsdl");   
   Object reply = client.invoke("HelloWorld", new Object[]{});
   Object[] replys=(Object[])reply;
   for(Object o:replys){
    System.out.println(o);
   }
    }

}

CXF 调用C#.net的WebService,布布扣,bubuko.com

CXF 调用C#.net的WebService

原文:http://www.cnblogs.com/hqbhonker/p/3876077.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!