webService学习案例

1.dos执行一个命令wsimort

D:\webService>wsimport -d . MobileCodeWS.xml
parsing WSDL...


[WARNING] Ignoring SOAP port "MobileCodeWSSoap12": it uses non-standard SOAP 1.2 binding.
You must specify the "-extension" option to use this binding.
  line 199 of file:/D:/webService/MobileCodeWS.xml

[WARNING] ignoring port "MobileCodeWSHttpGet": no SOAP address specified. try running wsimport with -extension switch.
  line 202 of file:/D:/webService/MobileCodeWS.xml

[WARNING] ignoring port "MobileCodeWSHttpPost": no SOAP address specified. try running wsimport with -extension switch.
  line 205 of file:/D:/webService/MobileCodeWS.xml


Generating code...


Compiling code...


D:\webService>wsimport -d . MobileCodeWS.xml
parsing WSDL...



Generating code...


Compiling code...


D:\webService>

注意:把MobileCodeWS.xml的199以后的配置信息删掉

或者用-s可以再webService生产源代码和class文件

D:\webService>wsimport -s . MobileCodeWS.xml
parsing WSDL...



Generating code...


Compiling code...


D:\webService>


注意:查看当前目录下  把copy  java文件

2.生产一个java客户端调用代码

把生产的java文件连同目录导入工程

3.创建一个工程,把代码导入

编写测试文件

package com.taxue.test;

import cn.com.webxml.MobileCodeWS;
import cn.com.webxml.MobileCodeWSSoap;

public class Mobiledemo {
	public static void main(String[] args) {
		MobileCodeWS ws = new MobileCodeWS();
		MobileCodeWSSoap port = ws.getMobileCodeWSSoap();
		String address = port.getMobileCodeInfo("13598362941", null);
		System.out.println(address);	
	}
}

结果:13598362941:河南 商丘 河南移动全球通卡

4.建立客户端调用

查看 xml wsdl说明书

1:提供Service <wsdl:service name ="MobileCodeWS">

2.获取 Port <wsdl:port name="MobileCodeWSSoap" binding="tns:MobileCodeWSSoap">

3.获得 proType 方法集合  <wsdl:binding name="MobileCodeWSSoap" type="tns:MobileCodeWSSoap">

4 寻找方法   <wsdl:operation name="getMobileCodeInfo">

5填写参数  调用方法得到结果


手机:http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值