JAVA使用axis调用WSDL的WebService


import javax.xml.rpc.ParameterMode;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;

public class caClient {

/**
* @param args
*/
public static void main(String[] args) {
try {
String endpoint = "http://ls.cqu.edu.cn/WebService/LibraryInterface.asmx?WSDL";
// 直接引用远程的wsdl文件
// 以下都是套路
Service service = new Service();

Call call = (Call) service.createCall();
call.setTargetEndpointAddress(endpoint);
call.setOperationName("SetLibraryValue");// WSDL里面描述的接口名称

call.setSOAPActionURI("http://ls.cqu.edu.cn/SetLibraryValue");
call.addParameter("Key", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
call.addParameter("XH", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
call.addParameter("HJDM", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
call.addParameter("BLSM", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
call.addParameter("SetState", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
call.addParameter("CZRID", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数
call.addParameter("LogIP", XMLType.XSD_STRING, ParameterMode.IN);// 接口的参数

call.setReturnType(XMLType.XSD_STRING);// 设置返回类型

String key = "ewfasdfdsafew23434";
String xh = "22";
String hjdm = "33";
String blsm = "33";
String ss = "33";
String cid = "33";
String ip = "33";
String result = (String) call.invoke(new Object[] { key, xh, hjdm, blsm, ss, cid, ip });

// 给方法传递参数,并且调用方法
System.out.println("result is " + result);
} catch (Exception e) {
System.err.println(e.toString());
}
}

}


上面的 WSDL 返回内容为:

<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://ls.cqu.edu.cn/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="http://ls.cqu.edu.cn/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://ls.cqu.edu.cn/">
- <s:element name="GetLibraryValue">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Key" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="XH" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="HJDM" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetLibraryValueResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetLibraryValueResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="SetLibraryValue">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Key" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="XH" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="HJDM" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="BLSM" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="SetState" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="CZRID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="LogIP" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="SetLibraryValueResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SetLibraryValueResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
- <wsdl:message name="GetLibraryValueSoapIn">
<wsdl:part name="parameters" element="tns:GetLibraryValue" />
</wsdl:message>
- <wsdl:message name="GetLibraryValueSoapOut">
<wsdl:part name="parameters" element="tns:GetLibraryValueResponse" />
</wsdl:message>
- <wsdl:message name="SetLibraryValueSoapIn">
<wsdl:part name="parameters" element="tns:SetLibraryValue" />
</wsdl:message>
- <wsdl:message name="SetLibraryValueSoapOut">
<wsdl:part name="parameters" element="tns:SetLibraryValueResponse" />
</wsdl:message>
- <wsdl:portType name="LibraryInterfaceSoap">
- <wsdl:operation name="GetLibraryValue">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><B>获取学生某环节办理情况</B><p> <span style='color:green'><B>参数说明:</B></span> Key:钥匙 XH:学号 HJDM:环节代码 </BR><span style='color:red'><B>返回值说明:</B> 0:未通过办理 1:已通过办理 420:批次未启用 430:钥匙错误 440:学号不存在或者该学生未进入离校系统 450:环节代码错误</span><BR/></wsdl:documentation>
<wsdl:input message="tns:GetLibraryValueSoapIn" />
<wsdl:output message="tns:GetLibraryValueSoapOut" />
</wsdl:operation>
- <wsdl:operation name="SetLibraryValue">
<wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"><B>设置学生某环节办理状态</B><p> <span style='color:green'><B>参数说明:</B></span> Key:钥匙 XH:学号 HJDM:环节代码 BLSM:办理说明 SetState:设置状态[1,0](分别为已通过和未通过) CZRID:办理人身份认证号 LogIP:办理人登陆IP</BR><span style='color:red'><B>返回值说明:</B> 200:设置成功 420:批次未启用 430:钥匙错误 440:学号不存在或者该学生未进入离校系统 450:环节代码错误 460:环节状态设置错误 470:写入日志出错</span><BR/><center>版权所有:Copyright 重庆大学 www.cqu.edu.cn</center></wsdl:documentation>
<wsdl:input message="tns:SetLibraryValueSoapIn" />
<wsdl:output message="tns:SetLibraryValueSoapOut" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="LibraryInterfaceSoap" type="tns:LibraryInterfaceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="GetLibraryValue">
<soap:operation soapAction="http://ls.cqu.edu.cn/GetLibraryValue" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="SetLibraryValue">
<soap:operation soapAction="http://ls.cqu.edu.cn/SetLibraryValue" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name="LibraryInterfaceSoap12" type="tns:LibraryInterfaceSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="GetLibraryValue">
<soap12:operation soapAction="http://ls.cqu.edu.cn/GetLibraryValue" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
- <wsdl:operation name="SetLibraryValue">
<soap12:operation soapAction="http://ls.cqu.edu.cn/SetLibraryValue" style="document" />
- <wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="LibraryInterface">
- <wsdl:port name="LibraryInterfaceSoap" binding="tns:LibraryInterfaceSoap">
<soap:address location="http://ls.cqu.edu.cn/WebService/LibraryInterface.asmx" />
</wsdl:port>
- <wsdl:port name="LibraryInterfaceSoap12" binding="tns:LibraryInterfaceSoap12">
<soap12:address location="http://ls.cqu.edu.cn/WebService/LibraryInterface.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值