请问下,web-app_2_4.xsd 和web-app_2_3.dtd有什么区别?
在web.xml上<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">写这个,自定义标签就出问题,换成2.3的就好了.
高手解决下
在web.xml上<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">写这个,自定义标签就出问题,换成2.3的就好了.
高手解决下
DTD是xml程序文档的文档类型定义,(document type definition)
说白了就是规范XML的数据格式。
由于DTD的一些先天不足,后来才引入了schema。你说的那个简单点说是servlet的版本。不同的定义文件决定了你在写xml的时候不同的格式。
<jsp-config>
<taglib>。</taglib>
</jsp-config>
<jsp-config>
<taglib>。</taglib>
</jsp-config>
这个不行,然后有错误,后台是没报错,但是前台显示不正常
Java代码
package com.enfang;
public class TestLiu {
public String getInfo(String aa){
return "webservice:"+aa;
}
} package com.enfang;
public class TestLiu { public String getInfo(String aa){
return "webservice:"+aa;
}
} 5.部署WebService 我们可以将需要公开的类文件复制到WEB应用目录下,并修改文件后缀名为jws。把类文件更名并放到WEB目录下?这样做并不好,它被暴露了。 所以在这里我们使用一个常量的部署方法,在工程中(根目录)添加一个deploy.wsdd文件:
Xml代码
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java=
"http://xml.apache.org/axis/wsdd/providers/java">
<service name="TestLiu" provider="java:RPC">
<parameter name="className" value="com.enfang.TestLiu"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="session"/><!-- request, session, or application -->
</service>
</deployment> <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="TestLiu" provider="java:RPC">
<parameter name="className" value="com.enfang.TestLiu"/>
<parameter name="allowedMethods" value="*"/>
<parameter name="scope" value="session"/><!-- request, session, or application -->
</service>
</deployment> 首先将工程部署到Tomcat服务器上,并启动Tomcat服务器。然后在工程上右键-->Run As...-->Run Configurations...,新建一个JavaApplication。在main页面中,project指定为我们的TestWebService,MainClass指定为org.apache.axis.client.AdminClient。在Arguments页面下设置Program arguments为-l http://localhost:8080/TestWebService/servlet/AxisServlet deploy.wsdd。点击Run按钮。 完成上面的操作后,AdminClient会为我们部署在Tomcat的TestWebService的WEB-INF目录下生成一个server-config.wsdd文件,它是提供给Axis使用的配置文件。 6.生成客户端
在根目录下建一个bat文件例如:WSDL2Java.bat,代码如下
Ruby代码
set Axis_Lib=.\WebRoot\WEB-INF\lib
set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
set Output_Path=.\src
set Package=client.webservice
set wsdl_path=http://localhost:8080/TestWebService/services/TestLiu?wsdl
%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -p%Package% %wsdl_path%
pause set Axis_Lib=.\WebRoot\WEB-INF\lib
set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
set Output_Path=.\src
set Package=client.webservice
set wsdl_path=http://localhost:8080/TestWebService/services/TestLiu?wsdl
%Java_Cmd% org.apache.axis.wsdl.WSDL2Java -o%Output_Path% -p%Package% %wsdl_path%
pause
然后执行这个文件生成客户端,客户端目录在src/client/webservice.
7调用webservice客户端
Java代码
package cn.anycall.test;
import java.rmi.RemoteException;
import javax.xml.rpc.ServiceException;
import client.webservice.*;
public class Test {
/**
* @param args
* @throws ServiceException
* @throws RemoteException
*/
public static void main(String[] args) throws ServiceException, RemoteException {
// TODO Auto-generated method stub
TestLiuService service = new TestLiuServiceLocator();
TestLiu_PortType client = service.getTestLiu();
String aa = client.getInfo();
System.out.println(aa);
}
} package cn.anycall.test;
import java.rmi.RemoteException;import javax.xml.rpc.ServiceException;import client.webservice.*;
public class Test { /**
* @param args
* @throws ServiceException
* @throws RemoteException
*/
public static void main(String[] args) throws ServiceException, RemoteException {
// TODO Auto-generated method stub
TestLiuService service = new TestLiuServiceLocator();
TestLiu_PortType client = service.getTestLiu();
String aa = client.getInfo();
System.out.println(aa);
}}