How to call service from a web a page ?

Topics: General Discussion Forum, July and December Releases Forum
Feb 12, 2008 at 4:30 AM

Hi,
After Creating the service, how can we use it in the Website which we are creating..
can anybody help me regarding this.

Thanks and Regards,
Nimesh Prabhakar

Feb 12, 2008 at 7:34 PM
Hi, it depends on ths implemntation tecnology you choused for your service, folow the Hands on Lab, so you publish your service & create ths proxies on the demo client, repeat ths same action on your web site....

Hope it help, regards
Juan Pablo
Feb 13, 2008 at 5:56 PM


nimesh wrote:

Hi,
After Creating the service, how can we use it in the Website which we are creating..
can anybody help me regarding this.

Thanks and Regards,
Nimesh Prabhakar



Nimesh,
If you implemented the service using WCF and you have WCF tools installed your version of Visual Studio, then you can right click on your web site/References folder and you should see an item in the pop-up menu "Add Service Reference...". If your service is running, then choose "Add Service Reference..." and put in the URI of the service, something like "http://localhost:xxxx/MyService/MyServiceReference.svc", and give it a meaningful name. You should now get some extra references listed in your References folder and you should now have a new folder "Service References" with a .map file and a .cs file listed.
In your code behind file for your page, assuming you are using C#, you will add a reference to the namespace "using WebApplication.MyServiceRef;". Now, on some event, pick any you want:
MyServiceContractClient proxy = null;
try
{
proxy = new MyServiceContractClient();
bool success = false;
success = proxy.SomeOperation();
if( success)
{
System.Console.Writeln("Yeah Me!");
}
else
{
System.Console.Writeln("Bummer!");
}
}
catch
{
System.Console.Writeln("Ooops!")
}
finally
{
if( proxy != null && proxy.State == System.ServiceModel.CommunicationState.Opened)
{
proxy.Close();
}
}
If you are not implementing with WCF, I don't have an answer for you at this time, since I have only done WCF implementations.
Sorry.
Developer
Feb 14, 2008 at 4:16 PM
You can generated the client proxy along with the service host with the "Host Model" (option Create Model, select Host Model).
There you can specify the technology and create a Host Application that expose the service implementation into the host project (Web App) and then create the Client Application that will in turn create the proxy in the client project that you selected.
These steps are well documented in the Building Hands-on labs and WSSF documentation as well.

CF
Feb 18, 2008 at 9:07 AM
hi,
I am implementing the service using WCF,a nd i have WCF tools installed on my system.
Here i have to use this service in a website.
I added webservice reference, but after adding i could saw some files generating in the HelloWolrd Folder.
1. HelloWorld.discomap
2. HelloWorld.wsdl
3. HelloWorld.xsd
4. HelloWorld0.xsd

In your previous post you have mentioed like after addign service reference 2 files will be listed, that is in the case of windows based application right ?

So if i wanna add reference in web based application what i have to do ?
more over how can i call it from the webpage using proxy.
My return value will be a string as well as my response also will be a string.

Hope u get my doubt....

Nimesh