java 怎样调用c#提供的webservice接口?
接口描述如下:DownloadTestLogsByTaskID根据测试任务ID下载测试日志相关文件。参数:strTaskID:任务IDiDowloadType:下载类型。...
接口描述如下:
DownloadTestLogsByTaskID
根据测试任务ID下载测试日志相关文件。
参数:
strTaskID: 任务ID
iDowloadType: 下载类型。0:ALL,1:日志,2:脚本
bIncludeDeleted: 是否包含已经删除的记录
输出:
打包压缩的文件对象
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
======================================
POST /WebService.asmx HTTP/1.1
Host: supertpa
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://WebService/SuperTPA/DownloadTestLogsByTaskID"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DownloadTestLogsByTaskID xmlns="http://WebService/SuperTPA">
<strUserGroup>string</strUserGroup>
<strTaskID>string</strTaskID>
<iDowloadType>int</iDowloadType>
<bIncludeDeleted>boolean</bIncludeDeleted>
</DownloadTestLogsByTaskID>
</soap:Body>
</soap:Envelope>
==================================== 展开
DownloadTestLogsByTaskID
根据测试任务ID下载测试日志相关文件。
参数:
strTaskID: 任务ID
iDowloadType: 下载类型。0:ALL,1:日志,2:脚本
bIncludeDeleted: 是否包含已经删除的记录
输出:
打包压缩的文件对象
SOAP 1.1
The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
======================================
POST /WebService.asmx HTTP/1.1
Host: supertpa
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://WebService/SuperTPA/DownloadTestLogsByTaskID"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<DownloadTestLogsByTaskID xmlns="http://WebService/SuperTPA">
<strUserGroup>string</strUserGroup>
<strTaskID>string</strTaskID>
<iDowloadType>int</iDowloadType>
<bIncludeDeleted>boolean</bIncludeDeleted>
</DownloadTestLogsByTaskID>
</soap:Body>
</soap:Envelope>
==================================== 展开
2个回答
展开全部
Java调用代码C#写的webservice例子:
/**
* @param:strTaskID 任务id
* @param:iDowloadType: 下载类型。0:ALL,1:日志,2:脚本
* @param:bIncludeDeleted: 是否包含已经删除的记录
* @return file object of log
* 2015年11月25日上午11:08:48
*/
public static String downloadTestLogsByTaskID(String strTaskID,String iDowloadType,boolean bIncludeDeleted){
File result = null;
try{
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName("", "GetTestQuestions"));
call.addParameter("strTaskID", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("iDowloadType", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("bIncludeDeleted", XMLType.XSD_BOOLEAN, ParameterMode.IN);
call.setTargetEndpointAddress(new URL("http://WebService/SuperTPA/DownloadTestLogsByTaskID"));
result = (File) call.invoke(new Object[] { strTaskID, iDowloadType,bIncludeDeleted});
}catch(Exception e){
e.printStackTrace();
}
return result;
}
public static void main(String args[]){
System.out.println(downloadTestLogsByTaskID("123456","1",true));
}
/**
* @param:strTaskID 任务id
* @param:iDowloadType: 下载类型。0:ALL,1:日志,2:脚本
* @param:bIncludeDeleted: 是否包含已经删除的记录
* @return file object of log
* 2015年11月25日上午11:08:48
*/
public static String downloadTestLogsByTaskID(String strTaskID,String iDowloadType,boolean bIncludeDeleted){
File result = null;
try{
Service service = new Service();
Call call = (Call) service.createCall();
call.setOperationName(new QName("", "GetTestQuestions"));
call.addParameter("strTaskID", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("iDowloadType", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("bIncludeDeleted", XMLType.XSD_BOOLEAN, ParameterMode.IN);
call.setTargetEndpointAddress(new URL("http://WebService/SuperTPA/DownloadTestLogsByTaskID"));
result = (File) call.invoke(new Object[] { strTaskID, iDowloadType,bIncludeDeleted});
}catch(Exception e){
e.printStackTrace();
}
return result;
}
public static void main(String args[]){
System.out.println(downloadTestLogsByTaskID("123456","1",true));
}
推荐于2017-12-16
展开全部
没错,就是上面的代码中,最简单是SOAP 的HTTP POST方式。。。。。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询