用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
相关文档:
1. HttpSession session = request.getSession()
与HttpSession session = request.getSession(true)的区别?
参考答案:
getSession(true)的函数原型为::HttpSession session = request.getSession (Boolean create)
如果有与当前的request先关联的HttpSession,那么返回request相关联的HttpS ......
1.Hibernate工作原理及为什么要用?
原理:
1.读取并解析配置文件
2.读取并解析映射信息,创建SessionFactory
3.打开Sesssion
4.创建事务Transation
5.持久化操作
6.提交事务
7.关闭Session
8.关闭SesstionFactory
为什么要用:
1. 对JDB ......
一 线程的基本概念
线程是一个程序内部的顺序控制流.一个进程相当于一个任务,一个线程相当于一个任务中的一条执行路径.;多进程:在操作系统中能同时运行多个任务(程序);多线程:在同一个应用程序中有多个顺序流同时执行;Java的线程是通过java.lang.Thread类来实现的;JVM启动时会有一个由主方法(public static void main( ......
import java.awt.image. * ;
import com.sun.image.codec.jpeg. * ;
public class poiReadDoc {
Image img = null;
int width = 0,height =0;
String destFile = "";
public void readImg(String fileName) throws IOException{
File _fil ......