请教,如何用ActionScript3.0来调用WebService呢?(补充问题)

dingjk007 dingjk007 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如题:
WebService带密码验证的,
要调用远程的WebService
可以提供点参考例子么?
我的代码如下,再往下本人就不会写了~:

public class getWebXml
{
var mWebSer1:WebService;
public function getWebXml()
{
mWebSer1 = new mx.rpc.soap.WebService();
mWebSer1.wsdl = ""; //这里是WebService的地址
mWebSer1.loadWSDL(ws1.wsdl);

}
}

WebService的帮助文档是:

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>


WebService的正式定义的服务说明如下:

<?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>



能否不调用后台,直接用AS来访问WebService来获得值呢?
麻烦达人们给点参考了!谢谢
...全文
评论 2
收藏 已收藏
分享
返回顶部
dingjk007
Flex 4,326 成员 9,103 内容