線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:2992
推到 Plurk!
推到 Facebook!

HTTP SOAPResponse error

尚未結案
Edward Chen
一般會員


發表:28
回覆:21
積分:9
註冊:2004-07-27

發送簡訊給我
#1 引用回覆 回覆 發表時間:2009-03-12 15:23:59 IP:220.132.xxx.xxx 訂閱
各位大大:在開發連接VS2005的Web server時引用wsdl importer產生了pas檔出來。後來引用之後發生 
EDOMPaserError with message Invaild unicode character"

其中:
function GetServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): ServiceSoap;
const
defWSDL = 'http://localhost:2340/HiAirService/emome.asmx?wsdl';
defURL = 'http://localhost:2340/HiAirService/emome.asmx';
defSvc = 'Service';
defPrt = 'ServiceSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as ServiceSoap);
if UseWSDL then
begin
//Because .net 2.0的Web service是UTF-8
RIO.HTTPWebNode.UseUTF8InHeader:=True;
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;

後來 引用的時候
begin
HTTPRIO:=THTTPRIO.Create(nil);
HTTPRIO.OnAfterExecute := RIOExcuted;
emome:=GetServiceSoap(True,'http://localhost:2340/HiAirService/emome.asmx?wsdl',HTTPRIO);
emome.SendPHSShortMessage('xxxxxxxxxx','xxxxxxxx','xxxxxxx');
end;
procedure TForm1.RIOExcuted (const MethodName: string; SOAPResponse: TStream);
begin
SOAPResponse.Position :=0;
Memo1.Lines.LoadFromStream(SOAPResponse);
end;

使用HTTPRIO.OnAfterExecute := RIOExcuted;事件所抓下來的xml內容
<?xml version="1.0" encoding="utf-8"?>http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> xmlns="520C1054�������������������������http://tempuri.org/">520C1054�������������������������
<!--l version="1.0" encoding="utf-8-->
真是非常的trouble,請予以指導
------
Signed by Edward Chen
編輯記錄
Edward Chen 重新編輯於 2009-03-12 15:29:25, 註解 無‧
Edward Chen 重新編輯於 2009-10-21 16:19:47, 註解 無‧
qoo1234
版主


發表:256
回覆:1167
積分:659
註冊:2003-02-24

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-03-14 10:43:53 IP:220.131.xxx.xxx 未訂閱
這應該是你的資料來源:
DELPHI调用C# WEBSERVICE_软件之路
http://hi.baidu.com/softways/blog/item/24c7f5ed34bbe14b79f05544.html
建議問問作者,或PO上你C#的東西上來.
Edward Chen
一般會員


發表:28
回覆:21
積分:9
註冊:2004-07-27

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-03-15 19:18:00 IP:219.86.xxx.xxx 訂閱
版本大大您好:
小弟是為了經由防火牆將中華電信的emome企業簡訊服務(TCP port 8001)透過VS2005的VB.NET寫XML Web service實現內部程式對外部的轉port(AP call 80轉8001)而實作的。之前已實作Fitel(大眾電信簡訊代理)成功了,想依樣畫壼蘆仿照,無奈遇到這種事!!
至於錯誤的發生在使用Delphi 7協同VS2005一起偵錯時(Step trace)發現在VS2005並無錯誤,錯誤的引起是在Delphi 7的SOAP接收之後引起的,目前的解決正朝向Indy 10更新(不知道是不是正確)
因為在VS2005段落Response時只簡單地回傳簡訊系統所傳回的Message Id(String),而Importer所製做出來的Function是WildString型別。
return Message.Id;
發生怪事才百思不得奇解,待我回到公司,立即貼上VS2005上的程式碼(dll的部份屬於TCP SOCKET封包拆解,就不再貼了,避混亂免影響判斷)

非常需要幫忙!!
------
Signed by Edward Chen
Edward Chen
一般會員


發表:28
回覆:21
積分:9
註冊:2004-07-27

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-03-16 08:08:55 IP:220.132.xxx.xxx 訂閱
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports SnsBridge

http://tempuri.org/")> _
_
_
Public Class Service
Inherits System.Web.Services.WebService
Private host As String
Private port As String
Private uid As String
Private pwd As String

_
Public Function SendPHSShortMessage(ByVal PhoneId As String, ByVal Sender As String, ByVal MessageContent As String) As String
Dim MessageId As String
host = ConfigurationManager.AppSettings("host")
port = ConfigurationManager.AppSettings("port")
uid = ConfigurationManager.AppSettings("uid")
pwd = ConfigurationManager.AppSettings("pwd")
Dim emome As New SnsBridge.emomeBridge(host, 8001)
emome.Login(uid, pwd)
If emome.Send(PhoneId, Sender & ":" & MessageContent) Then MessageId = emome.MessageId Else MessageId = ""
Return MessageId
End Function
_
Public Function GetMessageStatus(ByVal PhoneId As String, ByVal MessageId As String) As String
host = ConfigurationManager.AppSettings("host")
port = ConfigurationManager.AppSettings("port")
uid = ConfigurationManager.AppSettings("uid")
pwd = ConfigurationManager.AppSettings("pwd")
Dim emome As New SnsBridge.emomeBridge(host, 8001)
emome.Login(uid, pwd)
Dim MsgStatus As MessageStatus
MsgStatus = emome.DeliveryQuery(PhoneId, MessageId)
If MsgStatus = MessageStatus.Successed Then Return "成功" Else Return "失敗"
End Function
End Class
------
Signed by Edward Chen
編輯記錄
Edward Chen 重新編輯於 2009-03-16 08:10:16, 註解 無‧
系統時間:2024-04-24 18:20:11
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!