Thursday, July 27, 2006

Changing Web References in VS.NET 2005

.NET gives you the ability to call webservices methods within a web or desktop applications. The problem you may face is that the webservice URL can be changed and so your application may not be able to call the webservice correctly.

Each .NET project calls webservices methods will have a folder called "webreferences" which contains three files:

ServiceName.wsdl
ServiceName.disco
ServiceName.discomap

You will have to open these files with any editor, and update the URLs of the webservices with new URL or IP address.

Also, if your .NET project is web project, then you will need also to update the webservices URL in the web.config file.


Port Forwarding

If you have a server inside your LAN and you hope to access this server from WAN (ex: internet), unfortunatlly, you will not be able to access this server with out making some changes to your router configurations. So that, any requests comes from port 80 will be forwarded to the server LAN IP address.

For example, suppose you server local IP address is 198.65.1.144, and WAN address: 81.44.1.70. In your router configuration, forward any request comes on port 80 to 198.65.1.144. In this way, you will be able to access the server from the internet by addressing: http://81.44.1.70

Of course this not just for port 80, for example, you server may receives the HTTP requests on another port, say 8080. So, you do the previous steps as it is but with this port number. And you will be able to connect to server from the internet by addressing: http://81.44.1.70:8080


ASP Problem in IIS6 and Windows Server 2003

You may encounter a problem in running classic ASP in IIS6/Windows Server 2003. So you may try to test an ASP page on IIS6 and you get "Page Not Found" error. This is beacuase IIS6 by default doesn't enable any Scripting language. HTML is the only script enabled by default

To enable ASP Scripting, just open your IIS6 and on the left tree view. Click on "Web Service Extensions". The exiting extensions on the server will be listed. Click on “Active Server Pages” extension and enable it by clicking on “Allow” button. Then make a test ASP page and make sure that ASP scripting is working well.


Friday, July 21, 2006

Webservice Authentication

Suppose you have a collection of webservices resides in some server. You would like not to give a public access to these webservices. What shall you do?

Actually, you need some how an authentication mechanism to compromise the accessablity. One soultion would be to make an authentication webservice. Any client wants to access your webservices, should call it first. This webserice simply will take 2 parameters: username and password. The return value would be a hashcode.

This hash code could be used afterward in accessing any other webservice. The interfaces for example for your webservices could be something like that:

[C#]

string wsAuthenticate(string username, string password)
string wsAnyOtherWebservice(string accessCode, ... )

As you see, the returned hash code (access code) form wsAuthenticate will be used in accessing the other webservices and the client will not be able to get the service unless he have an account in your system.


Using SOAP Tool Kit 3.0 with VB Programs

Connecting to a webservice from a .NET desktop application is a piece of cake. But what about connecting to a webservice within unmanaged code - VB6/C++ programs? Actually SAOP Tool kit is the soultion. It is a Microsoft Tool used for calling webservices from unmanaged code.
You can download the kit from the Microsoft Official website:

http://www.microsoft.com/downloads/details.aspx?familyid=c943c0dd-ceec-4088-9753-86f052ec8450&displaylang=en

Here is a code snippt to call a webservice form inside VB6 program:



Dim soap As New SoapClient30
Dim serverURL as String
Dim hashCode as string

On Error GoTo ConnectionError

Public Sub WebServiceConnect

'Set Server URL
serverURL = "http://localhost/MyServiceName/Service.asmx?wsdl"

'Client is initialized
soap.MSSoapInit serverURL

'Calling the webservice
hashCode = soap.wsAuthenticate(txtUsername.Text, txtPassword.Text)

Exit Sub

ConnectionError:

MsgBox "Connection Error Encountered"

Exit Sub

The tool now is in its third version. Micorsoft declared that the SOAP tool kit 3.0 will not be supported after 31st March, 2008 because of the next generation of the Microsoft softwares will be .NET based. There will be no need to use SAOP tool kit as VS.NET gives already the ability to connect easily to webservices from the .NET desktop programs.