浏览 9495 次
锁定老帖子 主题:.net调用java webservice
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-05-26
最后修改:2011-06-23
在论坛上刚刚发布了java调用java中的webservice using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { WebReference.DemoService webservice = new WebReference.DemoService(); label1.Text = webservice.isflag(2); ServiceReference1.DemoClient d = new ServiceReference1.DemoClient(); label2.Text = d.isflag(123); } } }
/** * 调用.net 的 * @param rydm * @param iyear * @param imonth * @param opcoder * @return * @throws ServiceException * @throws MalformedURLException * @throws RemoteException */ public static String webServiceJxGz(String rydm,String iyear,String imonth,String opcoder) throws ServiceException, MalformedURLException, RemoteException{ String endpoint = "http://127.0.0.1:801/webjxxt/Service.asmx";//请求地址 Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setSOAPActionURI("http://tempuri.org/"); call.setUseSOAPAction(true); String namespace="http://tempuri.org/"; call.setOperationName(new QName(namespace, "WebJxGz")); //参数名称 及参数类型 call.addParameter(new QName(namespace,"srydm"),XMLType.XSD_STRING,ParameterMode.IN); call.addParameter(new QName(namespace,"iyear"),XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(namespace,"imonth"),XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); call.addParameter(new QName(namespace,"opcoder"),XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); //参数值 String s=(String)call.invoke(new Object[] { rydm,iyear,imonth,opcoder}); return s; }
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |