有沒有人與Delphi合作過的Bing Map Web Services(以前稱爲Virtual Earth Web Services)?根據我迄今爲止的經驗(都使用Delphi和Visual Studio C#),我準備放棄它並使用MapPoint Web服務,直到未來版本的Bing Maps Web服務發佈出來爲止。但是,我想我會在這裏發佈一個問題作爲最後的手段...任何人在Delphi中使用Bing Map Web Services?
我導入了令牌服務和地理編碼服務WSDL文檔。
我已經成功地從令牌服務獲取令牌,但一直無法讓Geocode服務工作。它始終返回以下錯誤消息: 由於EndpointDispatcher中的ContractFilter不匹配,無法在接收方處理帶有操作''的消息。這可能是因爲合同不匹配(發件人和收件人之間的操作不匹配)或發件人和收件人之間的綁定/安全性不匹配。檢查發送方和接收方是否有相同的合同和相同的綁定(包括安全要求,例如消息,傳輸,無)。
我注意到的Delphi沒有指定用於所述SOAPAction頭的值,所以我試圖指定「http://staging.dev.virtualearth.net/webservices/v1/geocode/contracts/IGeocodeService/Geocode」,獲得代替以下錯誤消息:
服務器無法處理請求由於內部錯誤。有關該錯誤的更多信息,請打開服務器上的IncludeExceptionDetailInFaults(來自ServiceBehaviorAttribute或<serviceDebug>配置行爲),以便將異常信息發送回客戶端,或者根據Microsoft .NET Framework打開跟蹤3.0 SDK文檔並檢查服務器跟蹤日誌。
下面是我的Delphi代碼和正在發送的原始XML,然後是通過類似Microsoft調用的示例C#代碼發送的原始XML。 XML有幾處不同之處,但我不確定關鍵是什麼區別。
var
Service: IGeocodeService;
Request: Geocode;
Response: GeocodeResponse3;
ResponseIndex: Integer;
Token: WideString;
Filters: ArrayOfFilterBase;
begin
Token := GetToken;
Service := GetIGeocodeService;
Request := Geocode.Create;
try
Request.request := GeocodeRequest.Create;
Request.request.Credentials := GeocodeService.Credentials.Create; // Freed by GeocodeRequest class
Request.request.Credentials.Token := Token;
Request.request.Query := AddressEdit.Text;
Request.request.Options := GeocodeOptions.Create;
SetLength(Filters, 1);
Filters[ 0 ] := ConfidenceFilter.Create;
ConfidenceFilter(Filters[ 0 ]).MinimumConfidence := GeocodeService.High_;
Request.request.Options.Filters := Filters;
Response := Service.Geocode(Request);
try
for ResponseIndex := Low(Response.GeocodeResult.Results) to High(Response.GeocodeResult.Results) do
begin
OutputMemo.Lines.Add(Response.GeocodeResult.Results[ ResponseIndex ].DisplayName);
end;
finally
Response.Free;
end;
finally
Request.Free;
end;
end;
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:NS2="http://dev.virtualearth.net/webservices/v1/geocode/contracts" xmlns:NS3="http://dev.virtualearth.net/webservices/v1/geocode" xmlns:NS4="http://dev.virtualearth.net/webservices/v1/common">
<NS1:Geocode xmlns:NS1="http://dev.virtualearth.net/webservices/v1/geocode/contracts">
<parameters href="#1"/>
</NS1:Geocode>
<NS2:Geocode id="1" xsi:type="NS2:Geocode">
<request href="#2"/>
</NS2:Geocode>
<NS3:request id="2" xsi:type="NS3:GeocodeRequest">
<Credentials href="#3"/>
<Options href="#4"/>
<Query xsi:type="xsd:string">Some Address</Query>
</NS3:request>
<NS4:Credentials id="3" xsi:type="NS4:Credentials">
<Token xsi:type="xsd:string">cbYkKgNlrsGnZbn3HRP7Xp5LJMv3RR_5qECwgB792COfY3EPmviaDpZ4mmD3fDP1Osc6fWUkTptog7bfgM73bA2</Token>
</NS4:Credentials>
<NS3:Options id="4" xsi:type="NS3:GeocodeOptions">
<Filters xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="NS3:FilterBase[1]">
<item href="#5"/>
</Filters>
</NS3:Options>
<NS3:ConfidenceFilter id="5" xsi:type="NS3:ConfidenceFilter">
<MinimumConfidence xsi:type="NS4:Confidence">High</MinimumConfidence>
</NS3:ConfidenceFilter>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<Geocode xmlns="http://dev.virtualearth.net/webservices/v1/geocode/contracts">
<request xmlns:a="http://dev.virtualearth.net/webservices/v1/geocode" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Credentials xmlns="http://dev.virtualearth.net/webservices/v1/common">
<ApplicationId i:nil="true"/>
<Token>pezCDpJoxdCG63NQdJUGkTrYYalnuSQDwuIC9FvheFAd9MIPO75qX9n7il0dx3eTEHlN2877PzN1_6YbQDL5tg2</Token>
</Credentials>
<Culture i:nil="true" xmlns="http://dev.virtualearth.net/webservices/v1/common"/>
<ExecutionOptions i:nil="true" xmlns="http://dev.virtualearth.net/webservices/v1/common"/>
<UserProfile i:nil="true" xmlns="http://dev.virtualearth.net/webservices/v1/common"/>
<a:Address i:nil="true" xmlns:b="http://dev.virtualearth.net/webservices/v1/common"/>
<a:Options>
<a:Count i:nil="true"/>
<a:Filters>
<a:FilterBase i:type="a:ConfidenceFilter">
<a:MinimumConfidence>High</a:MinimumConfidence>
</a:FilterBase>
</a:Filters>
</a:Options>
<a:Query>1 Microsoft Way, Redmond, WA</a:Query>
</request>
</Geocode>
</s:Body>
</s:Envelope>
謝謝,我試過類似的東西之前,但我只是沒有運氣又試了一次。 – 2009-07-13 18:33:01