4,327
社区成员




public class getWebXml
{
var mWebSer1:WebService;
public function getWebXml()
{
mWebSer1 = new mx.rpc.soap.WebService();
mWebSer1.wsdl = ""; //这里是WebService的地址
mWebSer1.loadWSDL(ws1.wsdl);
}
}
SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的“占位符”需替换为实际值。
POST /rt/Service.asmx HTTP/1.1
Host: 116.236.252.205
Content-Type: text/xml; charset=utf-8
Content-Length: “length”
SOAPAction: "http://tempuri.org/GetTrafficData"
<?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>
<GetTrafficData xmlns="http://tempuri.org/">
<strCustomID>“string”</strCustomID>
<strPassword>“string”</strPassword>
<strResult>“string”</strResult>
</GetTrafficData>
</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>
<GetTrafficDataResponse xmlns="http://tempuri.org/">
<GetTrafficDataResult>"string"</GetTrafficDataResult>
</GetTrafficDataResponse>
</soap:Body>
</soap:Envelope>
////////////////////////////////////////////////////
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的“占位符”需替换为实际值。
POST /rt/Service.asmx HTTP/1.1
Host: 116.236.252.205
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>
<GetTrafficData xmlns="http://tempuri.org/">
<strCustomID> "string" </strCustomID>
<strPassword> "string"</strPassword>
<strResult> “string”</strResult>
</GetTrafficData>
</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>
<GetTrafficDataResponse xmlns="http://tempuri.org/">
<GetTrafficDataResult> “string"</GetTrafficDataResponse>
</soap12:Body>
</soap12:Envelope>
////////////////////////////////////////////////////
HTTP GET
以下是 HTTP GET 请求和响应示例。所显示的“占位符”需替换为实际值。
GET /rt/Service.asmx/GetTrafficData?strCustomID=string&strPassword=string&strResult=string HTTP/1.1
Host: 116.236.252.205
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: "length"
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/"> "string”</string>
////////////////////////////////////////////////////
HTTP POST
以下是 HTTP POST 请求和响应示例。所显示的“占位符”需替换为实际值。
POST /rt/Service.asmx/GetTrafficData HTTP/1.1
Host: 116.236.252.205
Content-Type: application/x-www-form-urlencoded
Content-Length: “length”
strCustomID= “string "&strPassword= ”string “&strResult= ”string“HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: ”length“
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/"> “string”</string>
<?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://tempuri.org/" 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://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
- <s:element name="GetTrafficData">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="strCustomID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="strPassword" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="strResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetTrafficDataResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetTrafficDataResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetDataPassWord">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="strCustomID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="strPassword" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="strResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetDataPassWordResponse">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetDataPassWordResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
- <s:element name="GetTrafficResult">
- <s:complexType>
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="strCustomID" type="s:string" />
<s:element minOccurs="0" maxOccurs="1" name="strPassword" type="s:string" />
</s:sequence>
</s:complexType>
public function webAs()
{
//初始化WebService变量,并给wsdl属性赋值。wsdl属性将告诉WebService对象到哪里去找WSDL。
service.wsdl="http://*.*.*.*/xx.asmx?WSDL";
//在调用WebService方法前必须先调用loadWSDL方法,从指定的URL加载WSDL数据。
service.loadWSDL();
//给WebService对象添加侦听器,监听WSDL加载完成。
service.addEventListener(LoadEvent.LOAD,onWSDL);
//给WebService对象添加侦听器,监听出错的情况。
service.addEventListener(FaultEvent.FAULT,onFault);
}
private function onWSDL(evt:LoadEvent):void
{
var sss:String = "1111";
//为WebService方法添加侦听器,监听调用结果返回的情况。
service.Login.addEventListener(ResultEvent.RESULT,onLogin);
//为WebService方法添加侦听器,监听出错的情况。
service.Login.addEventListener(FaultEvent.FAULT,onFault);
//调用WebService方法。
service.GetTrafficData( "用户名","密码","状况");
}