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");
Ïà¹ØÎĵµ£º
dz̸Java·ºÐͱà³Ì
1 ÒýÑÔÔÚJDK 1.5ÖУ¬¼¸¸öеÄÌØÕ÷±»ÒýÈëJavaÓïÑÔ¡£ÆäÖÐÖ®Ò»¾ÍÊÇ·ºÐÍ£¨generics£©¡£·ºÐÍ£¨generics£¬genericity£©ÓÖ³ÆΪ“²ÎÊýÀàÐÍ»¯£¨parameterized type£©”»ò“Ä£°å£¨templates£©”£¬ÊǺͼ̳У¨inheritance£©²»Í¬¶ø»¥²¹µÄÒ»ÖÖ×é¼þ¸´ÓûúÖÆ¡£¼Ì³ÐºÍ·ºÐ͵IJ»Í¬Ö®´¦ÔÚÓÚ&mda ......
javaÖÐʱ¼ä´ÁºÍʱ¼ä×Ö·û´®Ö®¼äµÄת»»
»ñÈ¡µ±Ç°µÄunixʱ¼ä´Á
new Date().getTime()
System.currentTimeMillis()
·µ»ØµÄÊǺÁÃëÊý£¬Òª×ª»»long t = System.currentTimeMillis()/1000;
»ñÈ¡µ±Ç°ÄêÔÂÈÕÒÔ¼°Ê±·ÖÃë
Calendar c = Calendar.getInstance();
c.get(Calendar.YEAR)) c.get(Calendar.YEAR)) c.get(C ......
JAVAÀïµÄPINGÊÇÔÚJDK 1.5ºóÓÃÁËеĺ¯ÊýisreachableȥʵÏÖ,¾ßÌå½éÉÜÈçÏÂ:
InetAddress¶ÔÏóµÄ³£Ó÷½·¨
InetAddressÀàÓкܶà
get
·½·¨£¬ÓÃÀ´»ñÈ¡Ö÷»úÃû£¬Ö÷»úµØÖ·µÈÐÅÏ¢¡£Ö÷ÒªÓУº
byte[] getAddress() ·µ»Ø´Î
InetAddress
¶ÔÏóµÄÔʼ
IP
µØÖ·£¬±£´æΪһ¸ö
byte
Êý×é
String getCanonicalHostName() »ñÈ¡´Ë
I ......
ͨË×Àí½âÏòÉÏתÐÍ£º
¾ÍÊÇ×ÓÀàתÐͳɸ¸Àà¡£
class A{}
class B extends A { }
A b = new B();
Õâ¸ö¾ÍÊÇÏòÉÏתÐÍ¡£
ÏòÉÏתÐÍ¿ÉÒÔÏñÏÂÃæÕâÌõÓï¾äÕâô¼òµ¥:
Shape s =new Circle();
ÕâÀ´´½¨Ò»¸öCircle¶ÔÏ ......