HTTP GET POST - >如何同时使用两者? (.Net环境)

时间:2021-08-27 16:30:50

I am not the best with webservices......let me just preface this question with that.

我不是最好的网络服务......让我先用这个问题作为序言。

Anyways, I am attempting to write something that will contact a vendor's server and I have been reading their documentation.

无论如何,我试图写一些会联系供应商服务器的东西,我一直在阅读他们的文档。

They say that I need to submit a HTTP POST request, but I must also submit some configurations via an HTTP GET also.

他们说我需要提交HTTP POST请求,但我也必须通过HTTP GET提交一些配置。

I am confused when they say this as I didn't think that these could technically be done at the same time.

当他们这么说时我很困惑,因为我不认为这些技术可以在同一时间完成。

Essentially, I need to supply my required XML for the Post. :

基本上,我需要为Post提供所需的XML。 :

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<!DOCTYPE VendorZ>
<VendorZ Service='Info::Customers'>
<Addr>
        <City>toronto</City>
        <Country>ca</Country>
        <Region>on</Region>
        <Street>133 king st east</Street>
</Addr>
</VendorZ>

But then my url and password settings via a url in an http get. :

但是我的网址和密码设置通过http中的网址获取。 :

http://service.megaupload.com/mega/?Config=pwConfigSettings

I have reviewed a couple links on this website. :

我在本网站上查看过几个链接。 :

https://*.com/questions/92522/http-get-in-vb-net

https://*.com/questions/92522/http-get-in-vb-net

and

HttpWebRequest with POST and GET at the same time

HttpWebRequest同时使用POST和GET

But I am still fairly confused about how to go about doing this.

但我仍然对如何做到这一点感到困惑。

I know this isn't really that difficult, but hoping someone can shine some light on this. As I said I have read quite a few posts across the net, but it just isn't clicking for me today.

我知道这并不是那么困难,但希望有人可以对此有所启发。正如我所说,我已经在网上阅读了不少帖子,但它今天没有点击我。

Any advice/direction is greatly appreciated.

非常感谢任何建议/方向。

Thanks.

谢谢。

1 个解决方案

#1


1  

In some cases, sets of related network-accessible services are called "APIs" . As examples, Google has a "maps API", and Bing has a "search API". Facebook exposes their "Graph API".

在某些情况下,一组相关的网络可访问服务称为“API”。例如,Google有一个“地图API”,Bing有一个“搜索API”。 Facebook公开了他们的“图谱API”。

an aside:

一边:

By my mind, these aren't APIs according to the traditional definition: an application programming interface. Traditionally, an API is set of related function calls - or a class library in an OO environment - exposed by a library module. A programmer would link his code to a library in order to be able to call those APIs.

根据我的想法,这些不是传统定义的API:应用程序编程接口。传统上,API是由库模块公开的相关函数调用 - 或OO环境中的类库 - 的集合。程序员可以将他的代码链接到库,以便能够调用这些API。

These network-accessible functions are, to my mind, different. They are application network interfaces, not application programming interfaces. Maybe no one wanted to use the moniker ANI to describe these things. But let's be clear that we are talking about network interfaces here.

在我看来,这些网络可访问的功能是不同的。它们是应用网络接口,而不是应用程序编程接口。也许没有人想用名字ANI来形容这些东西。但是我们要清楚我们在这里谈论网络接口。

Within each ANI/API, whether from Google, Bing, Facebook, or someone else, there are typically numerous functions available. Each of these functions is independently available via some network protocol. In other words, a remote application sends a message, conforming to a particular data format, in order to "use" or "invoke" the function. Each of the network messages is different. Each has independent constraints and requirements.

在每个ANI / API中,无论是来自Google,Bing,Facebook还是其他人,通常都有许多功能可用。这些功能中的每一个都可通过某种网络协议独立获得。换句话说,远程应用程序发送符合特定数据格式的消息,以便“使用”或“调用”该功能。每个网络消息都是不同的。每个都有独立的约束和要求。

It sounds to me that some of the functions in the API you are using, require POST. Some require GET. When you want to use function A, then use HTTP POST and send a message formatted thusly; if you want to use function B, then use HTTP GET and format your request this way.

听起来你正在使用的API中的一些函数需要POST。有些人需要GET。如果要使用功能A,则使用HTTP POST并发送格式化的消息;如果你想使用函数B,那么使用HTTP GET并以这种方式格式化你的请求。

It could be as simple as that.

它可以这么简单。

You wouldn't use them at the same time. You'd use them from the same app, at different times.

你不会同时使用它们。您可以在不同的时间从同一个应用程序中使用它们。

#1


1  

In some cases, sets of related network-accessible services are called "APIs" . As examples, Google has a "maps API", and Bing has a "search API". Facebook exposes their "Graph API".

在某些情况下,一组相关的网络可访问服务称为“API”。例如,Google有一个“地图API”,Bing有一个“搜索API”。 Facebook公开了他们的“图谱API”。

an aside:

一边:

By my mind, these aren't APIs according to the traditional definition: an application programming interface. Traditionally, an API is set of related function calls - or a class library in an OO environment - exposed by a library module. A programmer would link his code to a library in order to be able to call those APIs.

根据我的想法,这些不是传统定义的API:应用程序编程接口。传统上,API是由库模块公开的相关函数调用 - 或OO环境中的类库 - 的集合。程序员可以将他的代码链接到库,以便能够调用这些API。

These network-accessible functions are, to my mind, different. They are application network interfaces, not application programming interfaces. Maybe no one wanted to use the moniker ANI to describe these things. But let's be clear that we are talking about network interfaces here.

在我看来,这些网络可访问的功能是不同的。它们是应用网络接口,而不是应用程序编程接口。也许没有人想用名字ANI来形容这些东西。但是我们要清楚我们在这里谈论网络接口。

Within each ANI/API, whether from Google, Bing, Facebook, or someone else, there are typically numerous functions available. Each of these functions is independently available via some network protocol. In other words, a remote application sends a message, conforming to a particular data format, in order to "use" or "invoke" the function. Each of the network messages is different. Each has independent constraints and requirements.

在每个ANI / API中,无论是来自Google,Bing,Facebook还是其他人,通常都有许多功能可用。这些功能中的每一个都可通过某种网络协议独立获得。换句话说,远程应用程序发送符合特定数据格式的消息,以便“使用”或“调用”该功能。每个网络消息都是不同的。每个都有独立的约束和要求。

It sounds to me that some of the functions in the API you are using, require POST. Some require GET. When you want to use function A, then use HTTP POST and send a message formatted thusly; if you want to use function B, then use HTTP GET and format your request this way.

听起来你正在使用的API中的一些函数需要POST。有些人需要GET。如果要使用功能A,则使用HTTP POST并发送格式化的消息;如果你想使用函数B,那么使用HTTP GET并以这种方式格式化你的请求。

It could be as simple as that.

它可以这么简单。

You wouldn't use them at the same time. You'd use them from the same app, at different times.

你不会同时使用它们。您可以在不同的时间从同一个应用程序中使用它们。