Struktur einer SOAP-Anwendung

Diskutiere Struktur einer SOAP-Anwendung im SOA Bereich.
T

thecain

Du hätst dich ja auch nicht an die mvn conventions... src/main/java, src/main/resources, src/test/java und src/test/resources
 
pkm

pkm

Stimmt, das war verkehrt, aber dieses:

1585815455311.png

...tut auch nicht, d. h. die Fehlermeldung ist nach wie vor

Exception in thread "main" javax.xml.ws.WebServiceException: Error while searching for service [javax.xml.ws.spi.Provider]
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61)
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58)
at javax.xml.ws.spi.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:70)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:89)
at javax.xml.ws.spi.Provider.provider(Provider.java:96)
at javax.xml.ws.Endpoint.publish(Endpoint.java:254)
at maven.localhost.quickstart.EmployeeServicePublisher.main(EmployeeServicePublisher.java:9)
Caused by: java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider com.sun.xml.ws.spi.ProviderImpl could not be instantiated
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:805)
at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:723)
at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
at javax.xml.ws.spi.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:63)
... 4 more
Caused by: java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:781)
... 7 more
Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference.
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:278)
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:273)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:310)
at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:273)
at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:98)
... 13 more
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
 
mrBrown

mrBrown

Oh, du solltest auch die JAXB-API als Dependency hinzufügen:
Code:
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
 
pkm

pkm

Ok, hab JAXB-API hinzugefügt, aber scheinbar ist das Problem irgendwie unlösbar, vgl. hier:


Und der Fehler bleibt daher:

Exception in thread "main" javax.xml.ws.WebServiceException: Error while searching for service [javax.xml.ws.spi.Provider]
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:61)
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:58)
at javax.xml.ws.spi.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:70)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:89)
at javax.xml.ws.spi.Provider.provider(Provider.java:96)
at javax.xml.ws.Endpoint.publish(Endpoint.java:254)
at maven.localhost.quickstart.EmployeeServicePublisher.main(EmployeeServicePublisher.java:9)
Caused by: java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider com.sun.xml.ws.spi.ProviderImpl could not be instantiated
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:583)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:805)
at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:723)
at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1395)
at javax.xml.ws.spi.ServiceLoaderUtil.firstByServiceLoader(ServiceLoaderUtil.java:63)
... 4 more
Caused by: java.lang.ExceptionInInitializerError
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:781)
... 7 more
Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference.
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:278)
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:273)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:310)
at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:273)
at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:98)
... 13 more
Caused by: javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:196)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:385)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:276)
... 17 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:192)
... 21 more
 
pkm

pkm

Danke, habe ich gemacht und auch viele Fehler beheben können. Derzeit bin ich bei:

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/org/apache/xml/internal/resolver/CatalogManager
at com.sun.xml.ws.client.WSServiceDelegate.createCatalogResolver(WSServiceDelegate.java:377)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:363)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:321)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:211)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:207)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:114)
at javax.xml.ws.Service.<init>(Service.java:112)
at maven.localhost.quickstart.EmployeeServiceTopDown_Service.<init>(EmployeeServiceTopDown_Service.java:40)
at maven.localhost.quickstart.EmployeeServicePublisher.main(EmployeeServicePublisher.java:11)
Caused by: java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.resolver.CatalogManager
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 10 more
Falls jemand durch einen Hack zum Beispiel eben diesen Fehler mal in einem anderen MVN-Projekt wegbekommen hat, bin ich jederzeit für Tipps dankbar, auch wenn ich langsam befürchte, dass meine Fehlerposts langsam zum Spam werden :D

Hier die aktuelle pom.xml:

XML:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>localhost</groupId>
  <artifactId>quickstart</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>quickstart</name>
  <url>http://maven.apache.org</url>

  <properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>javax.xml.ws</groupId>
    <artifactId>jaxws-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>javax.jws</groupId>
    <artifactId>javax.jws-api</artifactId>
    <version>1.1</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>rt</artifactId>
    <version>2.2.10</version>
</dependency>
<dependency>
    <groupId>javax.inject</groupId>
    <artifactId>javax.inject</artifactId>
    <version>1</version>
</dependency>
<dependency>
    <groupId>javax.xml</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.1</version>
</dependency>
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0-b170201.1204</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-ri</artifactId>
    <version>2.2.10</version>
    <type>pom</type>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.6</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.stream.buffer</groupId>
    <artifactId>streambuffer</artifactId>
    <version>1.4</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.0</version>
</dependency> 
<dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.3.1</version>
        <type>pom</type>
    </dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-xjc</artifactId>
    <version>2.2.11</version>
</dependency>
</dependencies>
</project>
 
Zuletzt bearbeitet:
pkm

pkm

Ich habe bin der Dependency-Hell durch Hinzufügen von folgender dependency Herr geworden:

XML:
<dependency>
<groupId>com.sun.org.apache.xml.internal</groupId>
<artifactId>resolver</artifactId>
<version>20050927</version>
</dependency>
 
pkm

pkm

Es tut leider immer noch nicht, daher wollte ich einmal in Bezug auf das bereits erwähnte baeldung-Tutorium einmal die grundsätzliche Frage stellen, was das „publishen“ eines Webservice eigentlich tut.

Ich habe auf port 8080 den Tomcat angeworfen und leider funktioniert das publishen aus folgendem Grunde nicht:

com.sun.xml.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.

java.net.ConnectException: Connection refused: connect

java.net.ConnectException: Connection refused: connect


at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:275)

at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:246)

at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:209)

at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:178)

at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:363)

at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:321)

at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)

at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:211)

at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:207)

at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:114)

at javax.xml.ws.Service.<init>(Service.java:112)

at maven.localhost.quickstart.EmployeeServiceTopDown_Service.<init>(EmployeeServiceTopDown_Service.java:39)

at maven.localhost.quickstart.EmployeeServicePublisher.main(EmployeeServicePublisher.java:11)
Ich verstehe nicht, wieso dieser Fehler kommt, denn ich habe doch den Namespace im Objekt QName des Service deklariert (in der Klasse EmployeeServiceTopDown_Service):


private final static QName EMPLOYEESERVICETOPDOWN_QNAME = new QName("http://localhost/employeeservicetopdown/",

"EmployeeServiceTopDown");

Hier meine wsdl-Datei:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<definitions
  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns:tns="http://localhost/employeeservicetopdown/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns="http://schemas.xmlsoap.org/wsdl/"
  targetNamespace="http://localhost/employeeservicetopdown/"
  qname="EmployeeServiceTopDown">
    <types>
        <xsd:schema
          targetNamespace="http://localhost/employeeservicetopdown/">
            <xsd:element name="countEmployeesResponse" type="xsd:int"/>
        </xsd:schema>
    </types>
 
    <message name="countEmployees">
    </message>
    <message name="countEmployeesResponse">
        <part name="parameters" element="tns:countEmployeesResponse"/>
    </message>
    <portType name="EmployeeServiceTopDown">
        <operation name="countEmployees">
            <input message="tns:countEmployees"/>
            <output message="tns:countEmployeesResponse"/>
        </operation>
    </portType>
    <binding name="EmployeeServiceTopDownSOAP"
      type="tns:EmployeeServiceTopDown">
        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
          style="document"/>
        <operation name="countEmployees">
            <soap:operation
              soapAction="http://localhost/employeeservicetopdown/
              EmployeeServiceTopDown/countEmployees"/>
            <input>
                <soap:body use="literal"/>
            </input>
            <output>
                <soap:body use="literal"/>
            </output>
        </operation>
    </binding>
    <service name="EmployeeServiceTopDown">
        <port name="EmployeeServiceTopDownSOAP"
          binding="tns:EmployeeServiceTopDownSOAP">
            <soap:address
              location="http://localhost:8080/employeeservicetopdown"/>
        </port>
    </service>
</definitions>

Hier der Service-Provider:
Java:
package maven.localhost.quickstart;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.WebServiceProvider;

@WebServiceProvider(serviceName = "EmployeeServiceTopDown", targetNamespace = "http://localhost/employeeservicetopdown/", wsdlLocation = "file:/C:/Users/andfe/Documents/eclipse-workspace/quickstart/src/main/java/employeeservicetopdown.wsdl")
public class EmployeeServiceTopDown_Service extends Service {

    private final static URL EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
    private final static WebServiceException EMPLOYEESERVICETOPDOWN_EXCEPTION;

    // "file://C:/Users/andfe/Documents/eclipse-workspace/quickstart/src/main/java/employeeservicetopdown.wsdl"
    // als QName oder
    // "http://localhost/employeeservicetopdown/"
    // ?

    private final static QName EMPLOYEESERVICETOPDOWN_QNAME = new QName("http://localhost/employeeservicetopdown/",
            "EmployeeServiceTopDown");

    static {
        URL url = null;
        WebServiceException e = null;
        try {
            url = new URL("http://localhost:8080/employeeservicetopdown");
        } catch (MalformedURLException ex) {
            e = new WebServiceException(ex);
        }
        EMPLOYEESERVICETOPDOWN_WSDL_LOCATION = url;
        EMPLOYEESERVICETOPDOWN_EXCEPTION = e;
    }

    public EmployeeServiceTopDown_Service() {
        super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME);
    }

    public EmployeeServiceTopDown_Service(WebServiceFeature... features) {
        super(__getWsdlLocation(), EMPLOYEESERVICETOPDOWN_QNAME, features);
    }

    public EmployeeServiceTopDown_Service(URL wsdlLocation) {
        super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME);
    }

    public EmployeeServiceTopDown_Service(URL wsdlLocation, WebServiceFeature... features) {
        super(wsdlLocation, EMPLOYEESERVICETOPDOWN_QNAME, features);
    }

    public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public EmployeeServiceTopDown_Service(URL wsdlLocation, QName serviceName, WebServiceFeature... features) {
        super(wsdlLocation, serviceName, features);
    }

    private static URL __getWsdlLocation() {
        if (EMPLOYEESERVICETOPDOWN_EXCEPTION != null) {
            throw EMPLOYEESERVICETOPDOWN_EXCEPTION;
        }
        return EMPLOYEESERVICETOPDOWN_WSDL_LOCATION;
    }

}



Und hier die Publisher-Klasse:

Code:
package maven.localhost.quickstart;

import javax.xml.ws.Endpoint;

public class EmployeeServicePublisher {

    public static void main(String[] args) {

        try {

            Endpoint.publish("http://localhost:8080/employeeservicetopdown", new EmployeeServiceTopDown_Service());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
 
Thema: 

Struktur einer SOAP-Anwendung

Passende Stellenanzeigen aus deiner Region:
Anzeige

Neue Themen

Anzeige

Anzeige
Oben