Javaµ÷ÓÃ.NETµÄWebService
1£® »ù±¾¿â
cxf-2.2.4.jar
XmlSchema-1.4.5.jar
Wsdl4j-1.6.2.java
2£® ÔÚ.NETÖбàд·þÎñ£¬Ä¬ÈϲÎÊý¼´¿É£¬È磺
namespace TestService2Java
{
[WebService(Namespace = "http://temp2java.org/")] //½ö´Ë´¦ÉÔ¼ÓÐ޸ģ¬²»¸ÄÒ²¿É
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public int MathAdd(int a, int b) //¶¨ÒåÒ»¸öз½·¨
{
return a + b;
}
}
}
3£® Éú³ÉJavaÖÐʹÓõÄÀ࣬ʹÓÃwsdl2java£º
wsdl2java –p test.net.service –d d:\src http://localhost/svr2java/Service1.asmx?wsdl
½«Éú³ÉÎļþÖеÄService1Soap.javaµ¼ÈëjavaÏîÄ¿¡£
±¸×¢£º//@XmlSeeAlso({ObjectFactory.class})£¬·ñÔòµ÷Óûá³ö´í¡£
4£® µ÷Ó÷þÎñ£º
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;
public class CallDotNetService {
public final static QName SERVICE = new QName("http://temp2java.org/", "Service1");
public final static QName Service1Soap = new QName("http://temp2java.org/", "Service1Soap");
private CallDotNetService() { }
public static void main(String args[]) throws Exception {
URL wsdlURL = new URL("http://localhost/svr2java/Service1.asmx?wsdl");
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
Ò»¡¢±³¾°
×î½üÒ»Äê¶àÀ´,ÔÚInternetÉϳöÏÖµÄÌرðÎüÒýÈ˵Äʼþ¾ÍÊÇJavaÓïÑÔºÍÓÃJava±àдµÄä¯ÀÀÆ÷HotJava¡£
1991Äê,SUNMicroSystem¹«Ë¾µÄJameGosling¡¢BillJoeµÈÈË,ΪÔÚµçÊÓ¡¢¿ØÖÆ¿¾Ãæ°üÏäµÈ¼ÒÓÃÏû·ÑÀàµç×Ó²úÆ·ÉϽøÐн»»¥Ê½²Ù×÷¶ø¿ª·¢ÁËÒ»¸öÃûΪOakµÄÈí¼þ(¼´Ò»ÖÖÏðÊ÷µÄÃû×Ö),µ«µ±Ê±²¢Ã»ÓÐÒýÆðÈËÃǵÄ×¢Òâ,Ö±µ½1 ......
Ò»¡¢±³¾°
×î½üÒ»Äê¶àÀ´,ÔÚInternetÉϳöÏÖµÄÌرðÎüÒýÈ˵Äʼþ¾ÍÊÇJavaÓïÑÔºÍÓÃJava±àдµÄä¯ÀÀÆ÷HotJava¡£
1991Äê,SUNMicroSystem¹«Ë¾µÄJameGosling¡¢BillJoeµÈÈË,ΪÔÚµçÊÓ¡¢¿ØÖÆ¿¾Ãæ°üÏäµÈ¼ÒÓÃÏû·ÑÀàµç×Ó²úÆ·ÉϽøÐн»»¥Ê½²Ù×÷¶ø¿ª·¢ÁËÒ»¸öÃûΪOakµÄÈí¼þ(¼´Ò»ÖÖÏðÊ÷µÄÃû×Ö),µ«µ±Ê±²¢Ã»ÓÐÒýÆðÈËÃǵ ......
Èç¹û´Ó·¿´Thinking in java ÕâÊéËãÆð£¬ÄÇÎÒÒѾ¿´Á˲¶àÈý¸öÔÂÁË£¬µ«ÊÇÊÂʵÉÏÕæÕý°Ñ»¨ÔÚ˼¿¼JAVAÎÊÌâÉϵÄʱ¼äËãÏ£¬¿ÉÕæÊÇÈÃ×Ô¼º¶¼Óеã˵²»¹ýÈ¥¡£ÖÖÖÖÀíÓɶ¼³ä³â×ÅÎÒµÄÉñ¾£¬µ«Î޷Ƕ¼ÊÇÀÁ¶èÕßµÄ×ÔÎÒ±£»¤µÄÊֶΣ¬ÎÒ²»µÃ²»¸Ð¿®ÕæµÄÊÇ×Ô¼ºÌ«²»ÉϽøÁË¡£
&nbs ......
1, ±£Ö¤Ḭ̈߳²È«µÄÈýÖÖ·½·¨: a, ²»Òª¿çÏ̷߳ÃÎʹ²Ïí±äÁ¿b, ʹ¹²Ïí±äÁ¿ÊÇfinalÀàÐ͵Äc, ½«¹²Ïí±äÁ¿µÄ²Ù×÷¼ÓÉÏͬ²½
2, Ò»¿ªÊ¼¾Í½«ÀàÉè¼Æ³ÉḬ̈߳²È«µÄ, ±ÈÔÚºóÆÚÖØÐÂÐÞ¸´Ëü,¸üÈÝÒ×.
3, ±àд¶àÏ̳߳ÌÐò, Ê×Ïȱ£Ö¤ËüÊÇÕýÈ·µÄ, Æä´ÎÔÙ¿¼ÂÇÐÔÄÜ.
4, ÎÞ ......