java客户端调用C++ GSoap生成的webservice

package com.test.webservice.client;

import java.rmi.RemoteException;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;

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

public class TestClent {

	public static void main(String[] args) {
		try {
			String endpoint = "http://www.cmsz.com:7088/getdbpwd/getdbpwdservice"; 
			Service service = new Service(); 
			Call call = (Call)service.createCall(); 
			call.setTargetEndpointAddress(endpoint);	

			call.setOperationName(new QName( 
					"urn:getdbpwd", "getdbpwd")); 
			call.addParameter( "pmsDBUser",null,javax.xml.rpc.ParameterMode.IN); 
			call.setReturnClass(String.class); 
			String temp = (String)call.invoke(new Object[]{"pubdba"}); 
			System.out.println("result: " + temp);
		} catch (ServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}


对应的WSDL 文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="getdbpwd"
 targetNamespace="http://www.cmsz.com:7088/getdbpwd/getdbpwd.wsdl"
 xmlns:tns="http://www.cmsz.com:7088/getdbpwd/getdbpwd.wsdl"
 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:ns="urn:getdbpwd"
 xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
 xmlns:MIME="http://schemas.xmlsoap.org/wsdl/mime/"
 xmlns:DIME="http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/"
 xmlns:WSDL="http://schemas.xmlsoap.org/wsdl/"
 xmlns="http://schemas.xmlsoap.org/wsdl/">

<types>

 <schema targetNamespace="urn:getdbpwd"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:ns="urn:getdbpwd"
  xmlns="http://www.w3.org/2001/XMLSchema"
  elementFormDefault="unqualified"
  attributeFormDefault="unqualified">
  <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/"/>
 </schema>

</types>

<message name="getdbpwdRequest">
 <part name="pmsDBUser" type="xsd:string"/>
</message>

<message name="getdbpwdResponse">
 <part name="password" type="xsd:string"/>
</message>

<portType name="getdbpwdPortType">
 <operation name="getdbpwd">
  <documentation>Service definition of function ns__getdbpwd</documentation>
  <input message="tns:getdbpwdRequest"/>
  <output message="tns:getdbpwdResponse"/>
 </operation>
</portType>

<binding name="getdbpwd" type="tns:getdbpwdPortType">
 <SOAP:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
 <operation name="getdbpwd">
  <SOAP:operation style="rpc" soapAction=""/>
  <input>
     <SOAP:body use="encoded" namespace="urn:getdbpwd" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </input>
  <output>
     <SOAP:body use="encoded" namespace="urn:getdbpwd" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </output>
 </operation>
</binding>

<service name="getdbpwd">
 <documentation>gSOAP 2.7.15 generated service definition</documentation>
 <port name="getdbpwd" binding="tns:getdbpwd">
  <SOAP:address location="http://www.cmsz.com:7088/getdbpwd/getdbpwdservice"/>
 </port>
</service>

</definitions>


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值