Visual Studio/Eclipse调用 JBoss5中的WebService
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的更多相关文章
- 【转】【UML】使用Visual Studio 2010 Team System中的架构师工具(设计与建模)
Lab 1: 应用程序建模 实验目标 这个实验的目的是展示如何在Visual Studio 2010旗舰版中进行应用程序建模.团队中的架构师会通过建模确定应用程序是否满足客户的需求. 你可以创建不同级 ...
- 在 Visual Studio 等编辑器/IDE中自动切换输入法,不需要手动的有没有?
使用Visual Studio写代码,经常遇到的一个问题就是切换中文输入法麻烦,输入完注释//,要切换到中文,输入完引号,要输入中文,然后还需要切换回来,有没有? 有时候中文输入法忽然失效有没有?明明 ...
- Visual Studio下Qt编程中对中文的处理
Visual Studio下Qt编程中对中文的处理 本文为原创文章,原文地址http://www.cnblogs.com/c4isr/p/qt_develop_in_vs.html Visual St ...
- 在visual studio的工程项目应用中打开console控制窗口
在visual studio的工程项目应用中打开console控制窗口,这个可以方便我们在console中输出参数的值检查错误. 只需要在需要打开console的地方加入下面的代码即可. AllocC ...
- Android使用ksoap2调用C#中的webservice实现图像上传
目录: 一. android使用ksoap2调用webservice 二. 异步调用 三. Android使用ksoap2调用C#中的webservice实现图像上传参考方法 四. 图像传输中Base ...
- 用DebuggerDisplay在Visual Studio的调试器中定制类的显示方式
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用DebuggerDisplay在Visual Studio的调试器中定制类的显示方式.
- 使用visual studio 2015调用阿里云oss .net sdk 2.2的putobject接口抛出outofmemory异常
问题描述: 使用阿里云oss .net sdk 2.2版本,使用putobject接口上传文件时,抛出outofmemory异常. 原因分析: 上传时,用于准备上传的数据缓冲区内存分配失败.与应用软件 ...
- Visual Studio扩展与更新中插件被禁用,安装后无法使用
在Visual Studio中的扩展与更新中安装插件后,显示[禁用],重新安装后仍然不能使用,但是VS默认安装的扩展却可以正常使用. 这里需要注意下方显示“当前不允许加载每用户扩展”,点击“启用每用户 ...
- 如何使用Visual Studio 2010在数据库中生成随机测试数据
测试在项目中是很重要的一个环节,在Visual Studio 2010中,在测试方面已经有很好的支持了,比如有单元测试,负载测试等等.在数据测试的方面,Visual Studio 2010,还支持对数 ...
随机推荐
- JS类型判断typeof PK {}.toString.call(obj)
参考链接:https://www.talkingcoder.com/article/6333557442705696719 先看typeof <!doctype html> <htm ...
- c bash 代码遍历文件夹下所有文件
用C代码.bash实现代码遍历文件夹下所有文件 递归方式实现如下: void listdir(char *path) { DIR *ptr_dir; struct dirent *dir_entry; ...
- Android内存优化11 内存泄漏常见情况2 内部类泄漏
线程持久化 Java中的Thread有一个特点就是她们都是直接被GC Root所引用,也就是说Dalvik虚拟机对所有被激活状态的线程都是持有强引用,导致GC永远都无法回收掉这些线程对象,除非线程被手 ...
- List 中的最大最小值
以下实例演示了如何使用 Collections 类的 max() 和 min() 方法来获取List中最大最小值: /* author by w3cschool.cc Main.java */ imp ...
- 体积雾 global fog unity 及改进
https://github.com/keijiro/KinoFog lighting box 2.7.2 halfspace fog 相机位于一个位置 这个位置可以在fog volumn里面或者外面 ...
- Ubuntu上安装samba不能安装的问题,“下列的软件包有不能满足的依赖关系”
前阵子,雨林木风版ubuntu下安装samba的问题,现在写出来分享一下. root@ubuntu:~# apt-get install samba正在读取软件包列表... 完成正在分析软件包的依赖关 ...
- linux 的计划任务 cron
https://serverfault.com/questions/587696/how-to-restart-php-fpm-from-cron 我也遇到了这个问题,想用cron 来启动php-fp ...
- Node.js制作图片下载爬虫的一般步骤
图片下载爬虫分两部分:爬页面和下载图片. 爬页面时先看网址是https还是http的,然后选择不同的内置对象: 其次看编码,如果是charset=gb2312的网页就需要iconv帮忙转码,好在大部分 ...
- redis学习笔记——命令执行流程
基础知识部分 如果需要掌握Redis的整个命令的执行过程,那么必须掌握一些基本的概念!否则根本看不懂,下面我就一些在我看来必备的基础知识进行总结,希望能为后面命令的整个执行过程做铺垫. 事件 Redi ...
- CCPlatformConfig(设置执行平台 iOS android win32等。。。)
#ifndef __CC_PLATFORM_CONFIG_H__ #define __CC_PLATFORM_CONFIG_H__ /** Config of cocos2d-x project, p ...