繁体   English   中英

如何使用Maven在Java中将侦听器设置为Salesforce出站消息?

[英]How to set up listener to salesforce outbound message in java using maven?

我正在尝试在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服务? 我可以用什么作为运行时环境来运行它? 雄猫会工作吗?

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

如果这对任何人都有帮助,我最终找到了进行此设置的教程。 照此进行,就可以了。 https://www.codenotfound.com/apache-cxf-spring-boot-soap-web-service-client-server-example.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM