用于 JAVAFX 应用程序的 Soap Web 服务客户端

如何解决用于 JAVAFX 应用程序的 Soap Web 服务客户端

我正在尝试为我的应用程序调用网络服务。如果我在示例项目中调用它,它运行得非常好。但是当我将它与 My Java FX 合并时,它给了我很多错误。 Web 服务客户端是使用 Eclipse 自动生成的。我只想调用方法。有人可以帮我吗?

Error: **Correction** I have edited it and I am using now JAVASE-15 and JVAFX-SDK 11.0.2
The package javax.xml.namespace is accessible from more than one module: java.xml,jaxrpc


Correction Update 2: I have removed Java.xml dependencies and module-info file as well.
but the new error is this

**Error: Could not find or load main class gload.Main
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application**

and IF I keep the module info file it shows:
**Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.graphics not found,required by gload**

型号:

package gload.model;


import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.swing.JOptionPane;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
import org.datacontract.schemas._2004._07.PE_PPER_MyPdmWebServiceClient_Data.CustomerItem;
import org.datacontract.schemas._2004._07.PE_PPER_MyPdmWebServiceClient_Data.Result;
import org.tempuri.IService;
import org.tempuri.ServiceLocator;

public class PdmData 
 {
   public String scode;
   public boolean state = false;

   
   
   public static String CdfFile;
    
    public static String pdflocation;
    
    public static String Custom_Ci;

    public static String Generic_Ci;
    
    public static String Mp_ref;
    
    public static String Interface;
    
    public static String Comments;
    
    public static String PersoAppli;
    
    public static String Code;
    public static String Revision;
    public static String Customer_Name;
    public static String Customer_reference;
    
    
    public static String getCode() {
        return Code;
    }

    public static void setCode(String code) {
        Code = code;
    }

    public static String getRevision() {
        return Revision;
    }

    public static void setRevision(String revision) {
        Revision = revision;
    }

    public static String getCustomer_Name() {
        return Customer_Name;
    }

    public static void setCustomer_Name(String customer_Name) {
        Customer_Name = customer_Name;
    }

    public static String getCustomer_reference() {
        return Customer_reference;
    }

    public static void setCustomer_reference(String customer_reference) {
        Customer_reference = customer_reference;
    }

    public static String getPersoAppli() {
        return PersoAppli;
    }

    public static void setPersoAppli(String persoAppli) {
        PersoAppli = persoAppli;
    }



    public static String getGeneric_Ci() {
        return Generic_Ci;
    }

    public static void setGeneric_Ci(String generic_Ci) {
        Generic_Ci = generic_Ci;
    }
   
      
    public static String getCdfFile() {
        return CdfFile;
    }

    public static void setCdfFile(String cdfFile) {
        CdfFile = cdfFile;
    }

    public static String getPdflocation() {
        return pdflocation;
    }

    public static void setPdflocation(String pdflocation) {
        PdmData.pdflocation = pdflocation;
    }


   
   public String Cdffile(String reference) {
       ServiceLocator locator = new ServiceLocator(); -------->Web Service Locator and call
        try {
            IService basicHttpBinding_IService = locator.getBasicHttpBinding_IService();
            Result result = basicHttpBinding_IService.getFilebyDcode(reference);
            
            //To download the files
            String link = result.getLocation();
            System.out.println(link);
           File out = new File("C:\\TempDownload\\" + reference +".zip");  //Creating a zip file to store the contents of download file
           new Thread(new Download(link,out)).start();
           //To Unzip the file
            Path source = Paths.get("C:\\TempDownload\\" + reference +".zip");
            Path target = Paths.get("C:\\TempDownload\\Unzip");

                try {

                    unzipFolder(source,target);
                    System.out.println("Done");

                } catch (IOException e) {
                    e.printStackTrace();
                }
                //Creating a File object for directory
                File directoryPath = new File("C:\\TempDownload\\Unzip\\Pre Ppc" + reference + "A_Released");
                //List of all files and directories
                String[] contents = directoryPath.list();
                System.out.println("List of files and directories in the specified directory:");
                FilenameFilter pdffilter = new FilenameFilter() {
                    public boolean accept(File dir,String name) {
                        String lowercaseName = name.toLowerCase();
                        if (lowercaseName.endsWith(".pdf")) {
                            return true;
                        } else {
                            return false;
                        }
                    }
                };
                     String[] contents1 = directoryPath.list(pdffilter);
                     for(String fileName : contents1) {
                         System.out.println(fileName);
                         setCdfFile(fileName);
                         setPdflocation(directoryPath.toString());
                      }
                   //To extract the Data From PDF

                        File file = new File(getPdflocation() + "\\" + getCdfFile());
                        //FileInputStream fis = new FileInputStream(file);

                        PDDocument document = PDDocument.load(file);
                        PDFTextStripper pdfReader = new PDFTextStripper();
                        String docText = pdfReader.getText(document);
                        System.out.println(docText);

                        document.close();
                        
                        //To extract details from document 
                        String CI_Ref = "CI Ref";
                        
                        int pos ;
                        pos = docText.indexOf(CI_Ref);
                        setGeneric_Ci(docText.substring(pos+7,pos+15));
                        System.out.println("Generic CI: " + getGeneric_Ci());

                        //To get Details of CI
                        CustomerItem customerItem = basicHttpBinding_IService.getCiDetails(getGeneric_Ci());
                        setPersoAppli(customerItem.getPersoAppli());
                        setCode(customerItem.getCode());
                        setRevision(customerItem.getRevision());
                        setCustomer_Name(customerItem.getCustomerName());
                        setCustomer_reference(customerItem.getCustomerReference());

        }catch (Exception e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null,"Unable to reach Service : " +  e.getMessage());
        }
    
        return getPersoAppli();
   }

模块信息文件

module gload {

    requires javafx.controls;
    requires javafx.fxml;
    requires java.desktop;

    requires java.rmi;
    requires java.base;
    requires axis;
    requires jaxrpc;
    requires org.apache.pdfbox;


    opens gload;
    opens gload.views.main;
    opens gload.utils;
    opens gload.model;
    opens gload.controllers;
    opens org.tempuri;
    opens org.datacontract.schemas._2004._07.PE_PPER_MyPdmWebServiceClient_Data;
}

如果我将 Jaxrpc 保留在类路径而不是模块路径中,我会收到这样的错误说明
无法解析 javax.xml.rpc.ServiceException 类型。它是从所需的 .class 文件间接引用的

解决方法

好的,这不是真正的答案,提供更多相关问题的指示以及提出解决方案的潜在方法。但我会将其作为答案发布,因为这样做可能比大量评论更好。

很遗憾,您有多个错误和问题,因此我会尝试单独处理其中的一些。


根据:

错误:

Error occurred during initialization of boot layer
java.lang.module.FindException: 
Module X not found,required by Y

可能在 --module-path 错误且无法找到模块时发生。可能,这至少是您的问题之一。链接的答案是针对 Idea 的,我不使用 Eclipse,所以我不知道如何解决 Eclipse 中的问题,但也许您可以进行一些研究以找出答案。


关于:

The package javax.xml.namespace is accessible from more than one module

有一些关于这里发生的事情的信息:

这个修复对我来说很棘手。请查看链接的问题和解决方案。看起来你要么需要

  1. 放弃 Java 9+ 模块化或
  2. 管理您的依赖项以不包含违反的传递依赖项或
  3. 改用不依赖损坏库的库(在这种情况下可能是首选解决方案)。

导致此问题的损坏库很可能是您使用的 jaxrpc 版本。我的猜测是,一些相关的 XML 库仅在 Java 9 中添加到标准 Java 中,但您使用的 jaxrpc 库是在此之前开发的。因此,jaxrpc 要么在其类中包含 XML 库,要么使用执行相同操作的传递库。这会导致冲突,因为 XML 库只能包含在项目中一次。


有关您的问题的更多信息在此答案中:

信息太丑了。 . .您可以阅读答案,它可能对您有所帮助,也可能使您沮丧。


您可以采取一些措施来帮助解决问题

对此应该怎么做有点棘手,这取决于您的技能水平以及您如何或是否可以解决它。我会就你可以做的一些事情提供一些建议,但还有其他选择。您比我更了解您的应用程序,因此您可以为您的应用程序提出更好的解决方案。

我建议将这些东西分开,作为故障排除的一种方式,获得一个适用于所有 JavaFX 组件的项目和一个适用于所有 SOAP 组件的项目,并确保它们构建并执行您想要的操作.然后尝试通过将它们集成到一个项目中或在单独的 VM 中运行它们并在两者之间进行通信来组合这两个项目(例如,通过添加的 REST API,尽管这是一个复杂得多的解决方案,因此在尝试之前请仔细考虑) ).

另外,升级到最新版本的 JavaFX。我认为它不会解决您的问题,但它不会受到伤害,并且最近的 JavaFX 版本中的一些改进可能已经做了一些可能有助于缓解您的一些问题的事情(尽管不是全部,因为有些您的问题源于模块化项目中 jaxrpc 的使用,这与 JavaFX 无关)。

此外,可能更重要的是,考虑使用不同的 SOAP 客户端框架,与 jaxrpc 似乎具有的损坏实现相比,它与模块化 Java 9+ 的交互效果更好。

就您是否应该使您的应用程序模块化(包括模块信息与否)而言,我真的不知道最适合您的方法。当然,无论您选择哪种方式,都会遇到问题。但是,问题以及如何解决这些问题会因选择的解决方案路径而异(我猜您在调查问题的过程中已经发现了)。

如有必要,将问题分解为单个单独的问题。如果您在解决每个单独的问题时需要帮助,请发布包含 minimal reproducible example 代码以复制问题的新问题。请注意,如果您这样做,代码绝对是最小的并且也是完整的,以便它只复制和询问一个问题,而不是多个问题的组合,并且问题是适当的标记 - 例如如果问题是关于 jaxrpc 和模块化,它应该包括 jaxrpc 和模块化标签,没有 JavaFX 代码或标签(反之亦然),当然,如果这不是问题的一部分,那么肯定在任何地方的 pdf 代码或依赖项上。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-