以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 HTML/XHTML/Ajax/Web 2.0/Web 3.0 』  (http://bbs.xml.org.cn/list.asp?boardid=22)
----  [求助]asp实现web services 传递xml  (http://bbs.xml.org.cn/dispbbs.asp?boardid=22&rootid=&id=86340)


--  作者:wdyllff
--  发布时间:8/19/2010 5:28:00 PM

--  [求助]asp实现web services 传递xml
用asp实现与web services传递信息 web services相应的信息如下:
RequestHandler
啟動服務流程(含電子案號)
測試
測試表單只適用於來自本機電腦的要求。
SOAP 1.1
下列是 SOAP 1.1 要求與回應的範例。預留位置顯示之處必須代入實際的值。
POST /SEWebApplication/SImediator.asmx HTTP/1.1
Host: www.cp.gov.tw
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/RequestHandler"

<?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>
    <RequestHandler xmlns="http://tempuri.org/">
      <SID>string</SID>
      <InputData>string</InputData>
      <Token2>string</Token2>
      <TicketNo>string</TicketNo>
    </RequestHandler>
  </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>
    <RequestHandlerResponse xmlns="http://tempuri.org/">
      <RequestHandlerResult>string</RequestHandlerResult>
    </RequestHandlerResponse>
  </soap:Body>
</soap:Envelope>
也就是说 asp 要实现与该web services传递信息就要实现上面的资讯,所以代码如下:

     strBody='<?xml version="1.0" encoding="utf-8"?>';
     strBody=strBody+'<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/">';
 strBody=strBody+'<soap:Body>';
               strBody=strBody+'<RequestHandler xmlns="http://tempuri.org/">';
 strBody=strBody+'<SID>PUB0000554</SID>';
 strBody=strBody+'<InputData></InputData>';
 strBody=strBody+'<Token2></Token2>';
 strBody=strBody+'<TicketNo></TicketNo>';
 strBody=strBody+'</soap:Body>';
 strBody=strBody+'</soap:Envelope>'; 
xmlHttp.open("POST", "http://www.cp.gov.tw/SEWebApplication/SImediator.asmx", false);  xmlHttp.setRequestHeader("HOST","www.cp.gov.tw");
 xmlHttp.setRequestHeader("Content-Type","text/xml; charset=utf-8");   xmlHttp.setRequestHeader("Content-Length",strBody.length);
 xmlHttp.setRequestHeader("SOAPAction","http://tempuri.org/RequestHandler");
 xmlHttp.send(strBody);

OK 到这边本来都好好的,SID、InputData、Token2、TicketNo这些节点填入相应的资料就可以的,但是问题来了,现在inpudata节点是要有另外一个xml,TicketNo是某个xml的一部分;所以不管我如何的把xml给填入到inpudata和TicketNo节点上,服务器的web services都回复是错的,所以在该出要怎么处理?如果是asp.net 应该就直接调用RequestHandler ( SID As string ,  InputData As string ,  Token2 As string ,  TicketNo As string ) As string 然后哦把xml当成字符串 传过去就可以了吧,但是asp 要怎么实现?大虾们 帮帮忙了


--  作者:wdyllff
--  发布时间:8/19/2010 5:32:00 PM

--  
使用到的参数xml如下

1.使用RequestHandler
SIMediator.RequestHandler("AGM0000737", InputXml, Token2, TicketNo)
2.InputXml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CPSecuredPortalReq xmlns="http://www.gov.tw/CP/cpsp_definition">
<CP_UserInfo>
<Profile>
<Type>公務人員</Type>
<Name></Name>
<EngName></EngName>
<UID></UID>
</Profile>
<ContactInfo>
<PostalAddress></PostalAddress>
<HomePhone>02-24236541:</HomePhone>
<TelephoneNumber>:</TelephoneNumber>
<Mobile></Mobile>
<Mail>a@mail.gsp.gov.tw</Mail>
</ContactInfo>
</CP_UserInfo>
<CP_PublicServiceInfo>
<MessageInfo>
<TicketID>10000178_0951227_000022_7641</TicketID> 勿用重複每次都不一樣
</MessageInfo>
<ServiceInfo>
<ServiceID>PUB000</ServiceID>
<ServiceName>氣象資料查詢</ServiceName>
<ServiceAction>Forecast-1</ServiceAction>
</ServiceInfo>
<ServiceStatus>
<Status/>
<Description/>
</ServiceStatus>
</CP_PublicServiceInfo>
<CP_AP_ServiceReq>
<Header>
<ServiceInfo>
<ServiceID>AGM000</ServiceID>
<ServiceName>氣象資料查詢</ServiceName>
<ServiceAction>Forecast-1</ServiceAction>
</ServiceInfo>
<ServiceStatus>
<Status/>
<Description/>
</ServiceStatus>
</Header>
<Body>
<LIServiceReqMsg xmlns="http://www.gov.tw/CP/cps_definition" xmlns:cwb="http://www.cwb.gov.
tw/webservices/cwb_definition" xmlns:cm="http://www.gov.tw/CP/cm_definition">
<ServiceInfo>
<cm:BusinessElementaryServiceOID>AGM0000737</cm:BusinessElementaryServiceOID>
<cm:ServiceName>氣象局</cm:ServiceName>
<cm:TicketNo>10000178_0951227_000022_7641</cm:TicketNo>
<cm:ServiceStatus></cm:ServiceStatus>
<cm:ServiceStatusDescription></cm:ServiceStatusDescription>
<cm:CPTest></cm:CPTest>
</ServiceInfo>
<ServiceDetailInfo>
<cwb:ForecastQuery>
<cwb:query>台灣地區36小時</cwb:query>
<cwb:預報地區>所有</cwb:預報地區>
</cwb:ForecastQuery>
</ServiceDetailInfo>
</LIServiceReqMsg>
</Body>
</CP_AP_ServiceReq>
</CPSecuredPortalReq>
3.傳入Token2 (從此token2標籤開始)
<Token2><TokenInfo Id="CP_AA_TokenInfo"><ID>6621f0a4-036d-4c34-86c9-d2e93f8c41da</ID><SecureLevel>
1</SecureLevel><TimeStamp><issue_date>20061228112752</issue_date><expire_date>
20061228114752</expire_date></TimeStamp><HolderInfo><uid>A123354075</uid><account>
A123354075</account></HolderInfo><SrvInfo><SID>PUB0000408</SID><Roles /><Objects
/></SrvInfo></TokenInfo><Signature Id="Signature_1553" myxmlns="http://www.w3.org/
2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-
20010315" /><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" /><Reference
URI="#CP_AA_TokenInfo"><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"
/><DigestValue>jseCcsgAh0Bdc++i2m3wr0+QXYg=</DigestValue></Reference></SignedInfo><SignatureValue>
D1hB14eb4zMwVynYH6kUfr84XBwcA3Z3Gf2hrFuz43yp+3Ny9kLRSqMznZRo/dDiJxaFjIvMekR8eIU3U83nBFPPh8i
a6mvQGWL45LKY5+J9c/UYHIW9lcq80fJCvIYTxXJCDNwLdDg79fbiKyshxsp49Lgz4IM1RPIV9lXTnu
k=</SignatureValue><KeyInfo><X509Data myxmlns="http://www.w3.org/2000/09/xmldsig#"><X509Certificate>
MIIDijCCAvOgAwIBAgIBAjANBgkqhkiG9w0BAQQFADA1MQswCQYDVQQGEwJU
VzEPMA0GA1UECh4GiExlP5ZiMRUwEwYDVQQLHgxRcZAaXnNT8ABDAEEwHhcN
MDQwNjE2MDkwMDQ1WhcNMzcwNjA4MDgwMDQ1WjBEMQswCQYDVQQGEwJUVzEP
MA0GA1UECh4GiExlP5ZiMRUwEwYDVQQLHgxRcZAaXnNT8ABDAEExDTALBgNV
BAsTBENQQUEwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL44ZRpoDoUn
thRRfyv2pWVgeSpEzbAcq30r7ytMHGxGK+pYgf86EqSu9YJdPRk8VcacciPNBZZIk/taWnit1VNaIBv+
BKQyDBxBVKzTT1dF2M/Mt4LABiKx/iP+W/kx7Pk0GM9BYpf1+aMh0825HWqhjWoOYc/laPZQxmeI+
VfNAgMBAAGjggGZMIIBlTAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBTdHrP0k
qUqgO3HdGbyMkZ1CvqElTBdBgNVHSMEVjBUgBRNu5uqV6k3HNa4jHnxrMEJq+
b3PqE5pDcwNTELMAkGA1UEBhMCVFcxDzANBgNVBAoeBohMZT+WYjEVMBMGA1UECx4MUXGQGl5zU/
AAQwBBggEBMAwGA1UdDwQFAwMH/4AwgcUGA1UdJQSBvTCBugYIKwYBBQU
HAwEGCCsGAQUFBwMCBggrBgEFBQcDAwYIKwYBBQUHAwQGCCsGAQUFBwMIBgo
rBgEEAYI3AgEVBgorBgEEAYI3AgEWBgorBgEEAYI3CgMBBgorBgEEAYI3CgMDBgorBgEEAYI3CgMEBglghkgBhvhCB
AEGCysGAQQBgjcKAwQBBggrBgEFBQcDBQYIKwYBBQUHAwYGCCsGAQUFBwMHB
ggrBgEFBQgCAgYKKwYBBAGCNxQCAjARBglghkgBhvhCAQEEBAMCBkAwHgYJY
IZIAYb4QgENBBEWD3hjYSBjZXJ0aWZpY2F0ZTANBgkqhkiG9w0BAQQFAAOBgQAVKIkC+
HvQ20jYu6vjegy0k6ooLVWDSdTjDv2vUGej0KekvbA3C7K/hFrWl+y5mjeHyFU66j2FxkFfcgSN+
06KiTTHSr4bLi0UebJwdkPW3Z1kctgv8TRzyLqSIvD+y/H4l2a3Jxs0ZBQi82VTMYYR6q8xi4XOcIxZCCppdYCzBg==</
X509Certificate></X509Data></KeyInfo></Signature></Token2>
4.TicketNo=10000178_0951227_000022_7641

[此贴子已经被作者于2010-8-20 11:16:35编辑过]

--  作者:wdyllff
--  发布时间:8/19/2010 5:41:00 PM

--  
顶起来啊 此帖 不能不解决
--  作者:Qr
--  发布时间:8/20/2010 9:50:00 PM

--  
这个发到web services 版会快些得到帮助:http://bbs.w3china.org/list.asp?boardid=10
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms