ÓÃJAX WSʵÏÖjavaµ÷ÓÃwebServic
À´¸ö¼òµ¥µãµÄ£º
1.½¨¸ö¾ßÌåµÄ·þÎñʵÏÖ£º
package com.webservice;
@WebService
public class Warehouse {
private Map<String, Double> prices;
public Warehouse() {
prices = new HashMap<String, Double>();
prices.put("Blackwell Toaster", 24.95);
prices.put("ZapXpress Microwave Oven", 49.95);
}
public double getPrice(@WebParam(name = "description")
String description) {
Double price = prices.get(description);
return price == null ? 0 : price;
}
}
2¡£Éú³É´æ¸ù£¨stub£© µÄclasses£¬ÔÚRMIÖÐÕâ»á×Ô¶¯Éú³É¡£WebServiceÖпÉÓÃJAX-WS¹¤¾ßÉú³É£º
½øµ½¹¤³ÌµÄclassesĿ¼Ï£º
wsgen -classpath . com.webservice.Warehouse
ÔÚcom.webservice.jaxwsÖлáÉú³ÉһЩclassÀ࣬ÔÚÕâÀïµÄÊÇGetPrice.classºÍGetPriceResponse.class
ÆäʵҲ¾ÍÊǰѲÎÊýºÍ·µ»ØÖµ°ü×°µÄÀà¡£
3¡£ÊÇʱºò²¿ÊðÁË£¬ÔÚÕâÀÎÒÃÇÓÃjdkÌṩµÄ¼òµ¥»úÖÆ£º
package com.webservice;
public class WarehouseServer {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/WebService/warehouse", new Warehouse());
}
}
ÔËÐкó£¬ÔÚä¯ÀÀÆ÷ÀïÇÃÉÏÉÏÃæµÄµØÖ· http://localhost:8080/WebService/warehouse?wsdl ¾Í¿ÉÒÔ¿´µ½WebServiceÌṩµÄÐÅÏ¢£º
<?xml version="1.0" encoding="UTF-8" ?>
- <!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.1 in JDK 6.
-->
- <!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.1.1 in JDK 6.
-->
- <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://webservice.com/" name="WarehouseService">
- <types>
- <xsd:schema>
<xsd:import namespace="http://webservice.com/" schemaLocation="http://localhost:8080/WebService/warehous
Ïà¹ØÎĵµ£º
ÔÚwindows×ÀÃæÉÏÓÒ»÷“ÎҵĵçÄÔ” —> “ÊôÐÔ” —> “¸ß¼¶” —> “»·¾³±äÁ¿”£¬Ôړϵͳ±äÁ¿”ÀïÎÒÃÇ¿ÉÒÔ¿´µ½ÏµÍ³µÄ¸÷¸ö»·¾³±äÁ¿µÄÖµ¡£Ë«»÷ij¸ö±äÁ¿Ãû¿ÉÒÔÐ޸ıäÁ¿Öµ£¬±äÁ¿ÖµÖ®¼äÓÓ;”¸ô¿ª¡£ÎÒÃÇ»¹¿ÉÒԓн¨”ÔÏÈÃ»Ó ......
×Ö·û´®
1¡¢»ñÈ¡×Ö·û´®µÄ³¤¶È
length()
2 ¡¢ÅжÏ×Ö·û´®µÄǰ׺»òºó׺ÓëÒÑÖª×Ö·û´®ÊÇ·ñÏàͬ
ǰ׺ startsWith(String s)
ºó׺ endsWith(String s)
3¡¢±È½ÏÁ½¸ö×Ö·û´®
equals(String s)
4¡¢°Ñ×Ö·û´®×ª»¯ÎªÏàÓ¦µÄÊýÖµ
intÐÍ Integer.parseInt(×Ö·û´®)
......
import java.util.*;
import java.text.*;
/**
* a <code> DateTime </code> ¶¨ÒåÁËÈÕÆÚʱ¼äµÄһЩ±ã½ÝµÄ¸ñʽ»¯²Ù×÷
*
* @version 1.0
* @author markhuang
*/
public class DateTime {
/**
* ´æ´¢Ê±¼äºÍÈÕÆÚ£¬Ä¬Èϵ±Ç°Ê±¼äºÍÈÕÆÚ
*/
// private Calendar cale = Calendar.getInstance ......