简体   繁体   English

C#使用XML API-无REST

[英]C# Consuming XML API - No REST

I was wondering how to consume a XML Service, which states: "CarTrawler's OTA Server does not expose a Web Services interface - ie no SOAP-discoverable WSDL. All messages are stateless and no session is maintained between calls.". 我想知道如何使用XML服务,该服务指出:“ CarTrawler的OTA服务器没有公开Web服务接口,即没有SOAP可发现的WSDL。所有消息都是无状态的,并且两次调用之间不维护会话。”

The service have targets URL's defined in order to send the requests. 服务已定义了目标URL,以便发送请求。

One possible request may be: 一个可能的请求可能是:

<?xml version="1.0" encoding="UTF-8"?>
<OTA_VehAvailRateRQ
  xmlns="http://www.opentravel.org/OTA/2003/05"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.opentravel.org/OTA/2003/05 OTA_VehAvailRateRQ.xsd"
  Target="Test" Version="1.005">
    <POS>
        <Source ISOCurrency="EUR">
            <RequestorID Type="16" ID="#####" ID_Context="####" />
        </Source>
    </POS>
    <VehAvailRQCore Status="Available">
        <VehRentalCore PickUpDateTime="2016-04-01T07:00:00" ReturnDateTime="2016-04-09T19:00:00">
            <PickUpLocation CodeContext="####" LocationCode="71" />
            <ReturnLocation CodeContext="####" LocationCode="71" />
        </VehRentalCore>
        <DriverType Age='30'/>
    </VehAvailRQCore>
    <VehAvailRQInfo PassengerQty='3'>
        <Customer>
            <Primary>
                <CitizenCountryName Code='IE' />
            </Primary>
        </Customer>
        <TPA_Extensions>
            <ConsumerIP>999.999.999.999</ConsumerIP>
        </TPA_Extensions>
    </VehAvailRQInfo>
</OTA_VehAvailRateRQ>

Maybe using HttpClient?, as it has no WSDL and I guess the service isn't REST. 也许使用HttpClient ?,因为它没有WSDL,而且我猜该服务不是REST。

This is no problem. 没问题 WSDL is just metadata to help you figure out the kind of data you should send or receive. WSDL只是元数据,可帮助您确定应该发送或接收的数据类型。 It doesn't mean that the service is not RESTful. 这并不意味着该服务不是RESTful的。

There are many tools that you can use to call a RESTful service. 您可以使用许多工具来调用RESTful服务。 This is my REST client: https://bitbucket.org/MelbourneDeveloper/restclient-.net 这是我的REST客户端: https : //bitbucket.org/MelbourneDeveloper/restclient-.net

NuGet: Install-Package RESTClient.NET NuGet:安装包RESTClient.NET

You should try just doing a simple GET as a string and see what gets returned. 您应该尝试仅执行一个简单的GET作为字符串,看看返回了什么。 If you post the Url of the API, I will try it. 如果您发布API的网址,我会尝试的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM