【问题标题】:How to set up listener to salesforce outbound message in java using maven?如何使用 Maven 在 Java 中设置 Salesforce 出站消息的侦听器?
【发布时间】:2023-03-13 07:16:01
【问题描述】:

我正在尝试在 java 中设置 salesforce 出站消息侦听器。这是我设置的链接,它工作正常 - https://developer.salesforce.com/page/Creating_an_Outbound_Messaging_Notification_Service_with_Eclipse_3.2

不幸的是,这篇文章在 2012 年之后从未更新过,出于显而易见的原因,我想将其设置为 maven 项目——这就是我遇到困难的地方。

我正在寻找合适的 maven 插件来基本上重现链接中的任何内容。我的想法是,我需要一个端点侦听器,以便它可以接收来自 salesforce 的肥皂消息。我现在有一个 wsdl 文件(我从 salesforce 获得),这是我的起点。端点也包含在 wsdl 中。 经过大量研究,我决定使用 apache cxf maven 插件从 wsdl 生成类。 我还有一个公共端点可用于接收消息。

但是,我被困住了,不确定如何从这里开始。获得课程后,如何配置端点侦听器? 在生成的类中,有一个接口 NotificationPort ,它具有在消息到达端点时调用的方法。我知道我需要一个实现接口的类。从现在开始如何运行和测试服务?

这是我的 pom.xml

        <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <cxf.version>3.1.11</cxf.version>
        <wsdl.generated.sources>${basedir}/src/main/java</wsdl.generated.sources>
    <wsdl.location>${project.basedir}/src/main/resources/META-INF/supplyorder.wsdl</wsdl.location>
    </properties>

      <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <version>${cxf.version}</version>
    </dependency>
  </dependencies>  
   <build>
    <plugins>
        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${wsdl.generated.sources}</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${wsdl.location}</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

wsdl相关部分

<!-- Binding 
     You need to write a service that implements this binding to receive the notifications
 -->
<binding name="NotificationBinding" type="tns:NotificationPort">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

    <operation name="notifications">
        <soap:operation soapAction=""/>
        <input>
            <soap:body use="literal"/>
        </input>
        <output> 
            <soap:body use="literal"/>
        </output>
    </operation>
</binding>

<!-- Service Endpoint -->
<service name="NotificationService">
    <documentation>Notification Service Implementation</documentation>
    <port binding="tns:NotificationBinding" name="Notification">
        <soap:address location="http://localhost:8080/SupplyOrder/Notification"/>
    </port>
</service>

问题: 1.我写了一个自定义类,实现了接口NotificationsPort。如何运行和测试此 Web 服务?我可以使用什么作为运行时环境来运行它? tomcat 能用吗?

  1. 无论如何我可以使用 Spring 来进行此设置吗? - 因为我非常喜欢使用它。

【问题讨论】:

    标签: java web-services soap wsdl salesforce


    【解决方案1】:

    如果这对任何人都有帮助,我终于找到了一个教程来设置这个。按照原样进行操作,您就可以开始了。 https://www.codenotfound.com/apache-cxf-spring-boot-soap-web-service-client-server-example.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 1970-01-01
      • 2016-03-13
      • 2023-03-19
      • 1970-01-01
      • 2023-03-07
      • 2022-06-18
      相关资源
      最近更新 更多