81,092
社区成员
发帖
与我相关
我的任务
分享
ControlDevice
测试
测试窗体只能用于来自本地计算机的请求。
SOAP 1.1
以下是 SOAP 1.1 请求和响应示例。所显示的占位符需替换为实际值。
POST /omp/Service/AjaxCallWS.asmx HTTP/1.1
Host: 172.16.10.200
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/ControlDevice"
<?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>
<ControlDevice xmlns="http://tempuri.org/">
<DId>string</DId>
<SValue>string</SValue>
</ControlDevice>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?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>
<ControlDeviceResponse xmlns="http://tempuri.org/">
<ControlDeviceResult>string</ControlDeviceResult>
</ControlDeviceResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /omp/Service/AjaxCallWS.asmx HTTP/1.1
Host: 172.16.10.200
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ControlDevice xmlns="http://tempuri.org/">
<DId>string</DId>
<SValue>string</SValue>
</ControlDevice>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ControlDeviceResponse xmlns="http://tempuri.org/">
<ControlDeviceResult>string</ControlDeviceResult>
</ControlDeviceResponse>
</soap12:Body>
</soap12:Envelope>
package com.candysee.test;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.encoding.XMLType;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis2.Constants;
public class TestWbservice {
public static void main(String[] args) {
// 远端调用的函数名
String method = "ControlDevice";
// webservice端口
String servicePoint = "http://172.16.10.200/omp/Service/AjaxCallWS.asmx";
// 默认命名空间
String xmlns = "http://tempuri.org/";
// SOAPAction
String SOAPAction = "http://tempuri.org/ControlDevice";
Service service = new Service();
Call call = (Call) service.createCall();;
try {
// 访问的webservice地址
call.setTargetEndpointAddress(new URL(servicePoint));
// 被调用的webservice方法
call.setOperationName(new QName(xmlns, method));
// 设置参数
call.addParameter("DId", XMLType.XSD_STRING, ParameterMode.IN);
call.addParameter("SValue", XMLType.XSD_STRING, ParameterMode.IN);
call.setUseSOAPAction(true);
// 返回值类型
call.setReturnType(Constants.XSD_STRING);
call.setSOAPActionURI(SOAPAction);
// 调用webservice方法
String resultlog = (String)call.invoke(new Object[] { "N0Y2MkE3MDEwMDRCMTIwMA==", "true"});
// 打印输出函数值
System.out.println(resultlog1);
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}