开发者

What is the most suitable .NET Web technology to implement this?

开发者 https://www.devze.com 2023-01-15 18:28 出处:网络
I will be interfacing with a third-party - the exchange of information is done as follows. If my application is the client and the third party is the server, then:

I will be interfacing with a third-party - the exchange of information is done as follows.

If my application is the client and the third party is the server, then:

  • Server-to-client: I give them a pre-defined URL and they push data with HTTP POST. The POST parameters contain a variable "xml" with the request in a proprietory XML format.
  • Client-to-server: this is done in a similar way only this time I originate the request (irrelevant to the question I gu开发者_高级运维ess)

Is this possible with WCF? If so, how? If not, ASP? MVC? Whatever the case, please give some pointers as to the specific steps.

Thank you

Edit: The response given is a HTTP 200 along with a proprietory XML response. Typically, the flow of data will be:

Server pushes request to client service => Generate response (usually will involve the client requesting the server to do something) => Give HTTP 200 back with response XML


I would suggest something along the lines of a WCF REST service. You could set it up to accept a POST request with a single string parameter. The string would then contain your XML, which you could load into an XDocument or something similar to parse your XML.

This might look something like this:

[OperationContract]
[WebInvoke(Method="POST")]
public string AcceptRequest(string Xml)
{
  // Do something here
}

You didn't really specify what you have to do with the post, or how you have to respond, so this might not work depending on those requirements.

Rick Strahl has a series of blog posts about WCF REST services, you might start here: http://west-wind.com/weblog/posts/310747.aspx.


I'd really wonder why you are doing old-school web services (custom XML over custom HTTP endpoint) in 2010. That said, I think in this scenario you probably want either:

a) Ye olde plain IHttpHandler taking raw input and returning a response.
b) An ASP.NET MVC App doing the same thing on a dedicated controller.

Decision really would get driven by what else you need to deploy with this app but either would work. Kickers here are responses are synchronous and the domain is relatively focused.

I think you could get there with WCF, but that adds so much configuration complexity to what is really a simple operation that it is probably best avoided.


I would take a look at WCF, without knowing detailed specifics of what you are doing I can tell you this.

Windows Communication Foundation (WCF) is created for communicating between a hosted service and a client, so it should do exactly what you want.

More information here MSDN WCF


I don't believe you can do this with WCF, though I'm no expert at WCF... If it were me I would create an ASP.Net ashx file for receiving the data and then create an aspx page where you can do a file upload/send using WebClient, or something along those lines.


imho you are mixing different technologies here.

Sure you could use classic asp.net, asp.net mvc and WCF to do so, but it begs the question: how do you need to run this? specially the request that you initiate, when its initiated?

WCF is designed precisely for communication scenarios, so it might be the most flexible option you have. What is not mentioned, is in response to what you need to initiate the request on your side.

It might be part of a page you are presenting to someone, in that case you also want asp.net (mvc) to initiate the operation. It might be needed to be run as a service, in which case you can stick to a WCF only solution. It might be needed to be initiated from a client application, in which case you also need said application.

Above said, if you already need to do asp.net (mvc) and the exchange is very simple, you could do it without introducing WCF. Less learning pieces.

Finally if HTTP POST + xml is not just a custom thing, but a web service call, you might want to stick to WCF to receive the requests. Specially as its possible you'll need other WS pieces, like WS-Security.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号