我正在尝试在 java 中设置 salesforce 出站消息监听器。这是我设置的链接,它工作正常 - https://developer.salesforce.com/page/Creating_an_Outbound_Messaging_Notification_Service_with_Eclipse_3.2
不幸的是,这篇文章在 2012 年之后从未更新过,出于显而易见的原因,我想将其设置为 Maven 项目 - 这就是我遇到困难的地方。
我正在寻找正确的 Maven 插件来基本上重现链接中的内容。我的想法是,我需要一个端点监听器,以便它可以从 salesforce 接收 SOAP 消息。现在我有一个 wsdl 文件(从 salesforce 获得),这是我的起点。端点也包含在 wsdl 中。 经过大量研究,我决定使用 apache cxf maven 插件从 wsdl 生成类。 我还有一个公共(public)端点可用于接收消息。
但是我被困住了,不确定如何从这里继续。获得类后,如何配置端点监听器?
从生成的类中,有一个接口(interface) NotificationPort
,该接口(interface)具有当消息到达端点时调用的方法。我知道我需要一个实现该接口(interface)的类。从现在开始我如何运行和测试该服务?
这是我的 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
接口(interface)的自定义类。如何运行和测试此 Web 服务?我可以使用什么作为运行时环境来运行它? tomcat 可以工作吗?
- 我可以使用 Spring 来进行此设置吗? -因为我非常愿意使用它。
最佳答案
如果这对任何人有帮助,我终于找到了一个进行此设置的教程。按照原样进行操作,就可以开始了。 https://www.codenotfound.com/apache-cxf-spring-boot-soap-web-service-client-server-example.html
关于java - 如何使用 maven 在 java 中设置 salesforce 出站消息的监听器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45687719/