1. HelloWebService.java

package com.xx.webservices;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService; @WebService
public class HelloWebService { @WebMethod
@WebResult(name="result")
public String sayHello(@WebParam(name="name")String name) {
System.out.println("sayHello:" + name);
return "你好,JBoss5 WebService 欢迎你:[" + name + "]";
} @WebMethod
@WebResult(name="result")
public int add(@WebParam(name="a")int a, @WebParam(name="b")int b) {
return a + b;
}
}

2. web.xml

	<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>com.xx.webservices.HelloWebService</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>

3. VS添加WebService引用后, Progam.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace HelloJBossService
{
class Program
{
static void Main(string[] args)
{
JBossHelloServiceRef.HelloWebServiceClient client = new JBossHelloServiceRef.HelloWebServiceClient();
JBossHelloServiceRef.add reqAdd = new JBossHelloServiceRef.add();
reqAdd.a = -11;
reqAdd.b = 22;
var rspAdd = client.add(reqAdd);
var ret = rspAdd.result;
Console.WriteLine(ret); //for (int i = 0; i < 10; i++)
//{
JBossHelloServiceRef.sayHello reqSay = new JBossHelloServiceRef.sayHello();
reqSay.name = "张三";
var rspSay = client.sayHello(reqSay);
Console.WriteLine(rspSay.result);
//}
Console.ReadKey();
}
}
}

Java端调用方法:

1. 在${jboss_home}/bin目录,在cmd中执行:

D:\DevPrograms\jboss\jboss-5.1.0.GA\bin>wsconsume.bat -k http://localhost:8080/HelloWorldJBoss5/hello?wsdl

生成代理文件.

2. 复制到java项目中

3. 添加测试代码

public class TestMain {

	/**
* @param args
*/
public static void main(String[] args) {
HelloWebServiceService svcProxy = new HelloWebServiceService();
HelloWebService svc = svcProxy.getHelloWebServicePort();
int c = svc.add(11, 22);
System.out.println(c); String ret = svc.sayHello("吴xx11");
System.out.println(ret);
} }

  

Visual Studio/Eclipse调用 JBoss5中的WebService的更多相关文章

  1. 【转】【UML】使用Visual Studio 2010 Team System中的架构师工具(设计与建模)

    Lab 1: 应用程序建模 实验目标 这个实验的目的是展示如何在Visual Studio 2010旗舰版中进行应用程序建模.团队中的架构师会通过建模确定应用程序是否满足客户的需求. 你可以创建不同级 ...

  2. 在 Visual Studio 等编辑器/IDE中自动切换输入法,不需要手动的有没有?

    使用Visual Studio写代码,经常遇到的一个问题就是切换中文输入法麻烦,输入完注释//,要切换到中文,输入完引号,要输入中文,然后还需要切换回来,有没有? 有时候中文输入法忽然失效有没有?明明 ...

  3. Visual Studio下Qt编程中对中文的处理

    Visual Studio下Qt编程中对中文的处理 本文为原创文章,原文地址http://www.cnblogs.com/c4isr/p/qt_develop_in_vs.html Visual St ...

  4. 在visual studio的工程项目应用中打开console控制窗口

    在visual studio的工程项目应用中打开console控制窗口,这个可以方便我们在console中输出参数的值检查错误. 只需要在需要打开console的地方加入下面的代码即可. AllocC ...

  5. Android使用ksoap2调用C#中的webservice实现图像上传

    目录: 一. android使用ksoap2调用webservice 二. 异步调用 三. Android使用ksoap2调用C#中的webservice实现图像上传参考方法 四. 图像传输中Base ...

  6. 用DebuggerDisplay在Visual Studio的调试器中定制类的显示方式

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用DebuggerDisplay在Visual Studio的调试器中定制类的显示方式.

  7. 使用visual studio 2015调用阿里云oss .net sdk 2.2的putobject接口抛出outofmemory异常

    问题描述: 使用阿里云oss .net sdk 2.2版本,使用putobject接口上传文件时,抛出outofmemory异常. 原因分析: 上传时,用于准备上传的数据缓冲区内存分配失败.与应用软件 ...

  8. Visual Studio扩展与更新中插件被禁用,安装后无法使用

    在Visual Studio中的扩展与更新中安装插件后,显示[禁用],重新安装后仍然不能使用,但是VS默认安装的扩展却可以正常使用. 这里需要注意下方显示“当前不允许加载每用户扩展”,点击“启用每用户 ...

  9. 如何使用Visual Studio 2010在数据库中生成随机测试数据

    测试在项目中是很重要的一个环节,在Visual Studio 2010中,在测试方面已经有很好的支持了,比如有单元测试,负载测试等等.在数据测试的方面,Visual Studio 2010,还支持对数 ...

随机推荐

  1. 利用谷歌API生成二维码

    http://chart.apis.google.com/chart?cht=qr&chs=104x104&chld=L|0&chl=http://www.cnblogs.co ...

  2. opencv Mat 像素操作

    1 cv::Mat cv::Mat是一个n维矩阵类,声明在<opencv2/core/core.hpp>中.   class CV_EXPORTS Mat { public: //a lo ...

  3. bootstrap table 复选框选中后,翻页不影响已选中的复选框

    使用的 jquery版本为 2.1.1 在项目中发现bootstrap table的复选框选中后,翻页操作会导致上一页选中的丢失,api中的 bootstrapTable('getSelections ...

  4. Javascript时间字符串比较

    //startdate和enddate的格式为:yyyy-MM-dd hh:mm:ss //当date1在date2之前时,返回1;当date1在date2之后时,返回-1:相等时,返回0 funct ...

  5. wamp php.ini 配置的坑

    wampserver是windows平台下一键部署PHP+apache+MySQL的开发环境安装包,非常方便,但修改php.ini时需要注意,wamp目录下有两个php.ini, 第一个是apatch ...

  6. Razor语法(三)

    1.定义变量 定义变量或声明常量必须在代码体内,代码体以'@{'开头,以'}'结束,其中定义变量以'var'进行声明.代码体内每行以';'做为结束标识. @{       var i = 10;    ...

  7. 【笔记】js Array.prototype.slice.call(arguments) 将函数的参数转换为数组方法的见解

    我们知道函数里面的参数实际上是一个以数组形式储存的对象 但它并非一个数组 如果我们要将它转换为数组可以调用Array.prototype.slice() 这个方法 分析一下这个方法: Array.pr ...

  8. C#中使用正则

      using System.Text.RegularExpressions;           private void button1_Click(object sender, EventArg ...

  9. .NET Framwork 之 托管代码的执行过程

    源代码代码第一次编译形成IL中间语言的托管代码,在运行时被Class Loader装载后进行JIT第二次编译形成托管的本地代码.在执行过程中,它会不断地检查当前我们执行的代码的安全性和规范性. Cla ...

  10. 树莓派学习笔记——GPIO功能学习

    0.前言     树莓派现在越来越火,网上树莓派的资料也越来越多.树莓派的学习可以分为linux系统学习和linux驱动学习,利用树莓派制作LED流水灯应该算是驱动学习吧.树莓派来自国外,国外嵌入式开 ...