使用Eclipse / Maven导入和使用经过身份验证的SAP WSDL

时间:2017-04-26 14:11:28

标签: eclipse maven soap wsdl sap

我有一个 ASP.NET(C#)项目,它基于使用来自德国SAP ERP的SOAP服务,我们最近决定将其移植到 Java动态Web项目。所有这些Web服务中的大多数都需要身份验证。

Visual Studio (ASP.NET)上,导入Web服务非常简单直接,就像单击Add service reference一样简单,放置 WSDL URL ,提供名称空间名称并单击Ok。完成。所有生成的类都将被“隐藏”,因此有人不会改变。太好了!另外,我们有一个绑定文件,它是纯XML,包含maxBufferSizemaxBufferPoolSizemaxReceivedMessageSize等内容......

Eclipse (Java)上,我尝试添加New Web服务客户端(新的> Web服务> Web服务客户端),这是我遇到第一个问题的地方。它就像由于某种原因无法将WSDL识别为有效的URL ,但是它可以在任何浏览器中工作(它甚至提示进行身份验证)和也在Visual Studio 项目中。这就是WSDL的样子:http://spceqsap01:8000/sap/bc/srt/wsdl/flv_10002A111AD1/bndg_url/sap/bc/srt/rfc/sap/zws_listar_municipios/300/zws_listar_municipios/zws_listar_municipios?sap-client=300 在示例中使用了一些WSDL,并且它们被“成功”导入,除了Eclipse抱怨一些JAR。我注意到的一个奇怪的事情是它们中的大多数都以?wsdl结尾,但是将它放在上面的WSDL中就不行了。

Maven 有一些插件可以生成WSDL的源代码,但我也无法让它工作(源代码没有生成或任何东西,可能是因为缺少一些插件配置或错误的)。如果某人有使用SAP Web服务的工作示例,请在下面发帖!

对于Java动态Web项目,我们目前正在使用以下内容:

  • Maven 3.3.9
  • Java 8
  • Tomcat 9
  • VRaptor 4.2
  • Hibernate 5.2.9
  • Eclipse Neon 4.6.1

这是我的pom.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">
    <!-- Artifact details -->
    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.nooder</groupId>
    <artifactId>portal</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <!-- Properties -->
    <properties>
        <deploy.version.log4j>2.8.2</deploy.version.log4j>
        <deploy.version.vraptor>4.2.0-RC5</deploy.version.vraptor>
        <deploy.version.weld>3.0.0.CR2</deploy.version.weld>
        <deploy.version.hibernate>5.2.9.Final</deploy.version.hibernate>
        <deploy.version.junit>4.12</deploy.version.junit>
        <deploy.version.slf4j>1.7.25</deploy.version.slf4j>
    </properties>

    <!-- Development and production settings -->
    <profiles>
        <profile>
            <id>tst</id>
            <properties>
                <deploy.enviroment>tst</deploy.enviroment>
            </properties>
        </profile>
        <profile>
            <id>prd</id>
            <properties>
                <deploy.enviroment>prd</deploy.enviroment>
            </properties>
        </profile>
    </profiles>

    <!-- Dependencies -->
    <dependencies>
        <!-- JUnit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${deploy.version.junit}</version>
        </dependency>

        <!-- VRaptor -->
        <dependency>
            <groupId>br.com.caelum</groupId>
            <artifactId>vraptor</artifactId>
            <version>${deploy.version.vraptor}</version>
        </dependency>

        <!-- VRaptor plugins -->
        <dependency>
            <groupId>br.com.caelum.vraptor</groupId>
            <artifactId>vraptor-java8</artifactId>
            <version>4.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>br.com.caelum.vraptor</groupId>
            <artifactId>vraptor-brutauth</artifactId>
            <version>4.0.4</version>
        </dependency>
        <dependency>
            <groupId>br.com.caelum.vraptor</groupId>
            <artifactId>vraptor-jpa</artifactId>
            <version>4.0.5</version>
        </dependency>
        <!-- 
        <dependency>
            <groupId>br.com.caelum.vraptor</groupId>
            <artifactId>vraptor-hibernate</artifactId>
            <version>4.1.0</version>
        </dependency>
        -->

        <!-- VRaptor's dependencies: Servlet Container (Tomcat) -->
        <dependency>
            <groupId>org.jboss.weld.servlet</groupId>
            <artifactId>weld-servlet-core</artifactId>
            <version>${deploy.version.weld}</version>
            <exclusions>
                <exclusion>
                  <groupId>org.jboss.spec.javax.el</groupId>
                  <artifactId>jboss-el-api_3.0_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.jboss.weld</groupId>
            <artifactId>weld-core-impl</artifactId>
            <version>${deploy.version.weld}</version>
            <exclusions>
                <exclusion>
                  <groupId>org.jboss.spec.javax.el</groupId>
                  <artifactId>jboss-el-api_3.0_spec</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- VRaptor's dependencies: Java 8 -->
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.18.1-GA</version>
        </dependency>

        <!-- VRaptor's dependencies: Bean Validation -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator-cdi</artifactId>
            <version>5.1.1.Final</version>
        </dependency>

        <!-- Hibernate + DB -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${deploy.version.hibernate}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>6.1.0.jre8</version>
        </dependency>

        <!-- JavaEE 8: CDI -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Tomcat's dependencies: JSTL -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Maven's dependencies (?) -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>

        <!-- Expression language -->
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
            <scope>provided</scope>
        </dependency>

        <!-- Log4j 2 -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${deploy.version.log4j}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${deploy.version.log4j}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>${deploy.version.log4j}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${deploy.version.slf4j}</version>
        </dependency>
    </dependencies>

    <!-- Build -->
    <build>
        <finalName>portal</finalName>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>

        <!-- Resources -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <filters>
            <filter>src/main/filters/settings.${deploy.enviroment}.properties</filter>
        </filters>

        <plugins>
            <!-- JDK Compiler Level -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerArgument>-parameters</compilerArgument>
                    <testCompilerArgument>-parameters</testCompilerArgument>
                </configuration>
            </plugin>

            <!-- Eclipse project -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <!-- Always download and attach dependencies source code -->
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <!-- Avoid type mvn eclipse:eclipse -Dwtpversion=2.0 -->
                    <wtpversion>2.0</wtpversion>
                </configuration>
            </plugin>

            <!-- For Maven Tomcat Plugin -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <path>/portal</path>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

任何输入非常赞赏!

0 个答案:

没有答案