Dear cprogramming administrators and members,
A greeting of peace. I hope everyone is in good health upon reading this forum.
I am currently studying Web services and tried some programming on my own, here's my code for a Web Service:
Code:
<%@ WebService language="C#" class="MyService" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
[WebService(Namespace="http://localhost/")]
public class MyService : WebService{
private String name;
[WebMethod]
public void setData(String n){
name = n;
}
[WebMethod]
public String getData(){
return name;
}
}
tried to "compile" using:
Code:
C:\InetPub\wwwroot\> WSDL http://localhost/MyService.asmx?WSDL
C:\InetPub\wwwroot\> csc /t:library MyService.cs
Then here's my C# console application that will use the Web service:
Code:
using System;
using System.IO;
namespace Win32{
class Hi{
public static int Main(String [] args){
MyService m = new MyService();
string name;
Console.WriteLine("Please enter name: ");
name = Console.ReadLine();
m.setData(name);
Console.WriteLine( "Hello there using Web Service. Your name is: "+m.getData() );
return 0;
}
}
}//end namespace
Then "compile" it again using:
Code:
C:\InetPub\wwwroot\> csc /r:MyService.dll Win32.cs
I just wonder when I tried to run it, the name I entered was not returned by the getData() method.
Is there missing in my code? I hope someone could help me here.
Thank you & God bless.
Respectfully Yours,
MarkSquall