有人使用Bing Map Web Services和Delphi吗?

Nat*_*ffe 9 delphi mapping soap web-services bing

有没有人使用Bing Map Web Services(以前的Virtual Earth Web Services)与Delphi合作?

根据我迄今为止的经验(使用Delphi和Visual Studio C#),我准备放弃它并使用MapPoint Web服务,直到Bing Maps Web Services的未来版本出现.但是,我以为我会在这里发一个问题作为最后的手段......

我导入了Token Service和Geocode Services WSDL文档.

我成功地从令牌服务中获取了令牌,但是根本无法让Geocode服务工作.它总是返回以下错误消息:由于EndpointDispatcher上的ContractFilter不匹配,无法在接收方处理带有Action''的消息.这可能是由于合同不匹配(发送方与接收方之间的操作不匹配)或发送方与接收方之间的绑定/安全性不匹配.检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息,传输,无).

我注意到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>
Run Code Online (Sandbox Code Playgroud)

gar*_*thm 3

我最好的猜测是,Delphi 似乎生成了太多的 Geocode 元素 - 在 C# 生成的 XML 中似乎没有任何与 NS2:Geocode 相对应的内容。如果您可以拦截 XML 并将其更改为如下所示,谁知道呢 - 它可能会起作用:

    ...
    <NS1:Geocode xmlns:NS1="http://dev.virtualearth.net/webservices/v1/geocode/contracts">
        <parameters href="#2"/>
    </NS1:Geocode>
    <NS3:request id="2" xsi:type="NS3:GeocodeRequest">
    ...
Run Code Online (Sandbox Code Playgroud)

另一个问题可能是 Bing 服务不支持 Delphi 组织 SOAP 请求的方式。

如果这不起作用,也许您可​​以找到另一个可以与 Delphi 一起使用的 SOAP 库 - 也许采用使用 C 或 COM 接口包装库的方法。