We have all the code in Delphi and it is hard to create a new ASMX / SVC File directly in .NET because it uses encryption and weird stuff :) as it would take around 2 weeks to convert and to test...
Because of that we agreed that will keep the Delphi code and find a way to communicate between the ASP.NET application and this Delphi code, so we generated a Delphi WebService that added to IIS is an ISAPI DLL.
My first question was:
Do I really need to set up IIS and install this WebService alone, or can I use it as a part of my project (just like an ASMX file) using any special trick?
and my 2nd question, it is been hard for me to provide the fellow information on how to convert pascal into .NET so we could, using the pascal code, output an ASMX for example... I can't find anything to do this.
We have Delphi Studio 2009 and it mention in several documents that we can do .NET (how?) and there is Delphi for .NET (are we talking about and only Delphi Prism here?).
Thank you guys!
New question that will resolve my 2 questions
How can I generate an ASMX (.NET Web Service) or SVC (.NET WCF Service) from a Delphi code?
I'm reading about Delphi Prism but I can't still figure it out.
If you have an ISAPI DLL then it is installed separately from the ASMX or other ASPNET artifacts. The ISAPI DLL is installed within the IIS Manager. It's either a Filter or Extension, and it's installed specially for each.
If it's an extension, then it is probably a thing that responds to http requests. If this is true, then it will handle a set of URLs that end with a particular suffix. For example, an ISAPI extension might be registered for all requests that end in ".foo", so if you tickle http://server/pagename.foo, the request will be handled by the extension. IIS7 calls these things "handlers".
If this Delphi thing is a filter, then it is probably a thing that injects itself into each http request, regardless of which application (ASPNET, something else) eventually handles the request, and regardless of the extension on the request. A filter can do authorization checks, authentication, URL rewriting, that sort of thing. And the way you would interact with a filter is via server variables, or ... in some cases like a rewrite filter, the action of the filter is completely transparent to the "page" logic. you can ignore the fact that a filter is present.
With an authorization filter, sometimes there are authorization cookes set on the request, and you'd get that via a server variable.
Related
This is more of an Architecture question, and I want to know all the possible pros and cons of the approach.
In my org, we have an ASP.NET Application, a Web API Project, and underlying DLLs which calls App Tier which is physically on different server. In ASP.NET Application, for a particular piece, we are having a SPA.
For most of the things (I would say 99 % of the things) , we are making ajax call from our SPA to Web-API to access underlying functionality.
SPA and WebAPI are both deployed and hosted on same Web Server as different applications and WebAPI has reference to underlying DLLs so these DLLs are deployed with WebAPI.
For one of the functionality some server side processing needs to be done on ASPX page's code behind.
I am suggesting to my team to do keep calling from SPA to WebAPI using http client and maintain loose coupling that we have between Application and the dlls via WebAPI, but many (I would say everybody else in my team) is in favor of adding direct reference of DLLs to ASP.NET application, so now these DLLs will be deployed with ASP.NET Application alongside.
Is my suggestion not so good provided ease of implementation that we would be getting with adding direct reference for DLLs in ASP.NET Application? Let me know if I am not explanatory enough.
I would be in favor of using a DLL directly if you could get rid of the Web API altogether. Since it does not sound like you are planning to do that, I think your suggestion to continue using the Web API from your application:
Using the DLL from two places creates a deployment liability: every time you update it, both places must be updated
Changing the code in DLL requires testing the change from two paths - A-D and A-W-D
Fixing a bug in the way that you call your DLL would likely have to go to both A and W, instead of going to W alone.
Of course, the path A-W helps you exercise your Web API component, too, helping you detect bugs early.
I'm looking at working my long-standing API to run on IIS rather than in a desktop app as it is now. Everything on the API is working so I'd rather not change too much if I don't have to. I know about the new Web API template in ASP.NET MVC 4 and I've worked with it, but I found that it didn't give me the control over everything that this particular project needs.
So my question is, is there any way to build an application for IIS that has something like an entry-point where I can just get a web request then use entirely my own code from there? Or do I have to build something that uses the Web API?
Yes, you'll want an ASP.NET handler.
How To Create an ASP.NET HTTP Handler by Using Visual C# .NET
http://support.microsoft.com/kb/308001
You'll need to handle parsing the request and serializing the result yourself. It's probably much better to create a web-api facade in front of your services than trying to do it manually.
I have some administrative methods under ASP .NET MVC website that is under https.
So it looks like
https://mysite.com/cms
and there are some actions like CheckUsers
My question is
Can we develop some external Windows Service to sign in to that website and execute some methods?
I mean how to do it technically (sign in and call methods?)
So tha chain is like that
Windows Service <---> call method CheckUsers() under
https://mysite.com/cms <---> other https://site2.com
I just need to automate execution of some methods and do it periodically with Windows Service.
It is a question of possible communication between Windows Service and ASP .NET MVC.
Any clue?
We've been using http://htmlunit.sourceforge.net/ for sending requests to third-party web sites. It allows you to send requests, receive response/status code/etc. Basically, its a small GUI-less browser which evaluates HTMKL, JavaScript, etc.
(it's a Java lib, so you could either google for a .Net port or use a converter to convert Java assembly into .Net assembly - see http://blog.stevensanderson.com/2010/03/30/using-htmlunit-on-net-for-headless-browser-automation/ for guidance. We've used the convertion approach).
If your requirements are less sophisticated, you can just use HttpClient or WebClient to send simple requests and parse responses manually.
NB: in case you're going to parse HTML manually, I suggest that you use Html Afgility Pack: this is the right way to parse HTML(mainly, because it "fixes" invalid tags, errors, etc).
I am a Java developer who has created a rather big Web service that works nice with Java clients or other tools (Soap UI).
One of our clients wants to write a .NET client for the web service and uses the "add service reference" feature of VS2010. According to the client this does not work since our WSDL and XSD files use "Forbidden XML constructs" as defined in this article:
The problem is that we have made heavy usage of xsd:attribute data in WSDL.
So the question is:
Is there a workaround to make .NET stub generation code compliant with WSDL/XSD files that contain xsd:attribute? Is there another .NET library for webservices that supports this feature?
Another question of mine would be why does Microsoft impose these limitations in the first place? Why xsd:attribute is a forbidden costruct in a web service??? Any clues on that?
Probably related: C#.NET Generating web service reference using WSDL (from XML schema) problem
If you have access to a machine with the .NET Framework on it why don't you use svcutil to generate a proxy/config settings for him and send it to him?
See www.svcutil.com for the list of switches and options that are available to you
I have found that if the customer cannot do it one way and you provide a documented (possibly automated) way of doing things then that will generally suffice.
I have tested the HelloWorld.wsdl supplied in the link with the .NET version of Remobjects (http://www.remobjects.com) and it seemed to work fine. I don't have an actual service to test this with but I would suggest that you (or the client :) ) download it and give it a try.
The .NET version can be found here:
http://www.remobjects.com/ro/net.aspx
Apparently the answer is that you should NOT use the modern way of generating stubs with svcutil.exe and instead use the legacy way with wsdl.exe
Creating stubs from the command line with wsdl.exe works fine. The resulting code works as expected and the .NET client connects to the Axis2 Web service.
I want to implement a restful service in ASP.NET. I want it to be compatible with .Net 2.0 and IIS 5+. I am constrained to not use ASP.NET MVC or REST starter kit. By reading on internet I have learned that it can be implemented using HTTPHandlers. The problem is, the request will come in as a POST request. And I want to URL to be like:
http://abc.com/MyService/MyMethod1/
and
http://abc.com/MyService/MyMethod2/
Any workarounds for this?
Thanks,
Vamyip
Your best option is to use URL Rewriting. This is non-trivial in IIS5. The methods I know of are as follows:
Method 1 - ISAPI filter
These are low-level modules that allow you to manipulate the incoming request. Programming one of these is hairy and tough to debug. If you go this route, you are better off using one that has already been built like ISAPI_Rewrite.
Method 2 - IHttpModule
These are managed ASP.Net modules that are easy to add/remove from your application. Again, you are better off using a pre-built component like UrlRewriter.NET. The issue with using one of these, (as BrainLy mentions), is that you have to configure IIS 5 to map all incoming requests to ASP.Net as follows (link):
Open Up IIS and Navigate to the “Home Directory Tab”
Select “Configuration”
Click “Add” and enter “C:\WINNT\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll” in the Executable box. For the file extension, enter “.*”. Finally, make sure that “Check that file exists” is not checked.
One interesting thing to note is that ASP.Net is itself an ISAPI module :)
Once you are able to manipulate URLs using one of these tools, you can easily rewrite the RESTful urls to be handled by your default.aspx page (or whatever handler you choose to use).
If you can allow the restriction of only IIS 7.0 and above you could use URL Rewrite http://www.iis.net/download/URLRewrite to do that pretty easily.
Can I ask why is it that you need to support IIS 5+? That is an 11 year old technology that hopefully people will move out of those platforms in favor of more recent versions. Also keep in mind support for some of those platforms is ending pretty soon.
If the concern is developers running Windows XP I would point out that IIS Express includes version 7.5+ functionality and is available for all platforms Windows XP and above.
I think this will be difficult to do because IIS 5 will not let you handle non ASP.NET file extensions without some additional configuration in IIS. That means you are limited to URLs ending in .aspx etc. To handle URLs like those in your examples you need to map ASP.NET to handle all URLs in IIS, implement some type of URL rewriting, or introduce some kind of hacky 404 redirection.
Once you have the correct mapping in place you can wire up an IHttpHandler, but you will have to parse the incoming request yourself to work out which is /MyService/MyMethod1/ and which is for /MyService/MyMethod2/. If your methods are simple then it is easy to do this with a regular expression.
You should start with a simple handler like this one.