如何使用 maven 在 java 中设置侦听器以销售出站消息?



我正在尝试在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 生成类。 我还有一个可用于接收消息的公共终结点。

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

这是我的绒球.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 服务?我可以使用什么作为运行时环境来运行它?雄猫会起作用吗?

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

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

最新更新