A:. NET establishes webservice, which is called in Java.
1. Create a new web in VS
Simply modify Service.cs's [WebMethod] code:
Using System;
Using System.Web;
Using System.Web.Services;
Using System.Web.Services.Protocols;
[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = wsiprofiles.basicprofile1_1)]
public class Service:System.Web.Services.WebService
{
Public Service () {
If you are using a design component, uncomment the line
InitializeComponent ();
}
[WebMethod]
public string Netsayhi (string name) {
Return "Hello!" +name;
}
}
You can run to see if the creation was successful.
2. Create another Web site to obtain the WSDL file.
3. Add a Web Reference
4, here, the purpose is achieved--produced the WSDL file we want.
5. Create a new Java project in MyEclipse.
6. Copy the service.wsdl file you just made in. NET to SRC and create a new new WebService Client
If you notice the error, do not bother, direct finish.
6. Org.tempuri This package and the following file will be generated automatically, find the Serviceclient.java file double-click.
7. Modify the Main method under it, in fact, is to write a code just.
public static void Main (string[] args) {
ServiceClient client = new ServiceClient ();
Servicesoap service = Client.getservicesoap ();
System.out.println (Service.netsayhi ("Villain!"));
}
Run the test, you will generally succeed!
B.java Create a WSDL file,. NET call.
1, create a new Web Project, create a new interface and corresponding implementation class;
Package com.yenange.ws;
public class Teacher implements Iteacher {
public string Javasayhi (string name) {
Return "Hello everyone, I am" +name+ "teacher";
}
}
2. Add a Web service support package.
3, modify services.xml this configuration file.
http://xfire.codehaus.org/config/1.0 ">
Javaws
Com.yenange.ws
Com.yenange.ws.ITeacher
Com.yenange.ws.Teacher
4. Test whether the Java-established webservice is successful.
http://localhost:8080/javaWS/services/javaws?wsdl
In IE, click menu to save as a.wsdl file. Put it under the d:/.
5, the following steps are to convert the a.wsdl file into a a.dll file;
6. In the Start menu, enter Visual Studio 2005 command prompt.
7. Enter the following command:
Convert a.wsdl files to A.cs
D:/>wsdl/n:xyz/out:a.cs a.wsdl
Where/n:xyz indicates that the namespace namespace is xyz
Convert A.cs to A.dll
D:/>csc/out:a.dll/t:library A.cs
8. Create an ASP. NET Web site in VS and pull a label in the Default.aspx.
9. Add a reference to bring in the previously generated a.dll.
10. Write the test code in Default.aspx.cs:
protected void Page_Load (object sender, EventArgs e)
{
Xyz.javaws ws=new xyz.javaws ();
This. Label1.Text = Ws.javasayhi ("What Month");
}
11. Run, there should be no problem.
. NET and Java build WebService and call each other