一个简单的Hello.jws如下:
public class Hello
{
public String hello(String name)
{
if(name==null)
name = "";
return "你好"+name+",欢迎来到Web服务的世界!";
}
}
本机调用
http://localhost:8080/axis/Hello.jws?method=hello,得到以下结果(中文
都成了? :():
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance">
- <soapenv:Body>
- <helloResponse soapenv:encodingstyle="http://schemas.xmlsoap.org/soap/enco
ding/">
<helloReturn xsi:type="xsd:string">???????Web??????</helloReturn>
</helloResponse>
</soapenv:Body>
</soapenv:Envelope>
如果传入中文参数(
http://localhost:8080/axis/Hello.jws?method=hello&name=路人
甲),还会得到这个错误
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>java.io.UTFDataformatException: Invalid byte 2 of 2-byte UTF-8
sequence.</faultstring>
<detail />
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
小弟初学Axis,还望各位大侠多多帮助
--
FROM 218.193.179.*