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. TJSONTableObject跨平台解析JSON

    TJSONTableObject跨平台解析JSON USES SynCrossPlatformJSON TSQLRecordPeoplePersistent = class(TPersistent) ...

  2. matlab中cell array的理解

    1. matlab中有一个函数iscell() 用于判断一个数组是不是cell array 参考:MATLAB Function Reference iscell Determine whether ...

  3. VUE -- router 传参和获取参数

  4. Lua学习笔记之开始

    在这节课的开始,按照国际惯例,一般学习一门新的语言,都是要打印出“Hello,world”,那么我们也不例外. Lua语言的打印跟其他语言一样,只要print(“Hello,World”),然后保存为 ...

  5. text-align 属性,输入框数字向右靠

    1.业务需求:金额输入框数字向右靠 2.HTML文件 <td id="otherPay_Td"> <input id="otherPay" t ...

  6. 用BETTERCAP和RASPBERRY PI ZERO W制作迷你WiFi干扰器

    我并不是一个特别勤快的人,几天前我终于开始将我几周以来的一些想法付诸于实践,即使用Raspberry Pi Zero W制作一个可随身携带的迷你WiFi干扰器.有了它,我就可以随时随地的收集附近无线接 ...

  7. TensorFlow------TFRecords的分析与存储实例

    TensorFlow------TFRecords的分析与存储实例: import os import tensorflow as tf # 定义cifar的数据等命令行参数 FLAGS = tf.a ...

  8. CCControlExtension/CCControlButton

    #ifndef __CCCONTROL_BUTTON_H__ #define __CCCONTROL_BUTTON_H__ #include "CCControl.h" #incl ...

  9. ci框架(二)

    自定义SQL语句                                                                             当提供的API满足不了我们对S ...

  10. 基于c++11新标准开发一个支持多线程高并发的网络库

    背景 新的c++11标准出后,c++语法得到了非常多的扩展,比起以往不论什么时候都要灵活和高效,提高了程序编码的效率,为软件开发者节省了不少的时间. 之前我也写过基于ACE的网络server框架,但A ...