gpt4 book ai didi

java - 从ant调用WS

转载 作者:行者123 更新时间:2023-12-01 15:54:45 25 4
gpt4 key购买 nike

我编写了一个java WS并托管它

@WebService
public class DBConnectionCheck{

@WebMethod
public synchronized boolean dbServerState(final String SERVERNAME,final String USER_ID,final String USER_PASSWORD
,final String VENDOR,final String PORT,final String CONNECTOR_TYPE)
{
.............}
@WebMethod
@WebMethod
public synchronized boolean oracleDBState(......)
{
..............
}

我已经生成了 stub 并编写了客户端......

      public class CheckRegressionStatus {



public static void main(String args[]) throws PreRequisticException
{

Properties resourceMangerProps = new Properties();

/**
* Instantiate the generated Service
*/
com.cordys.autopilot.InfraStructure.servercheck.stub.ReadInfraResourceAvaliabiltyService service1 = new com.cordys.autopilot.InfraStructure.servercheck.stub.ReadInfraResourceAvaliabiltyService();

com.cordys.autopilot.InfraStructure.servercheck.stub.ReadInfraResourceAvaliabilty res = service1.getReadInfraResourceAvaliabiltyPort();

/**
* Instantiate the generated Service
*/
com.cordys.autopilot.InfraStructure.dbstate.stub.DBConnectionCheckService service = new com.cordys.autopilot.InfraStructure.dbstate.stub.DBConnectionCheckService();


com.cordys.autopilot.InfraStructure.dbstate.stub.DBConnectionCheck dbConnectionCheckProxy = service.getDBConnectionCheckPort();

从 Eclipse 或 Netbeans 调用时效果非常好

但是当我编写一个ant代码来调用它时

<java classname="....InfraStructure.CheckRegressionStatus">                 
<classpath>
<pathelement path="XYZ.jar"/>
</classpath>
</java>

抛出以下错误

  [java] javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not f
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:747)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:201)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:104)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
[java] at java.lang.reflect.Method.invoke(Method.java:597)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:357)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:698)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:199)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
[java] Caused by: javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.Provide
[java] at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:33)
[java] at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:128)
[java] at javax.xml.ws.spi.Provider.provider(Provider.java:83)
[java] at javax.xml.ws.Service.<init>(Service.java:56)

最佳答案

您使用的是 JDK 1.6 吗?

默认情况下,该类 com/sun/xml/internal/ws/spi/ProviderImpl 位于 JDK 1.6 rt.jar 中。您很可能已使用正确的 JDK 设置 Eclipse,但尚未将 Ant 设置为使用 JDK 1.6。

关于java - 从ant调用WS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5297612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com