• Talend Webservice的简单实现


    目的:用Talend将获取的数据用webservice的形式发布接口

    实现:

    1、在Services下增加我们的Webservice,里面定义要实现的方法以及输入输出等。

    我们也可以通过Source来直接编辑WSDL文件,附demo代码:

    <?xml version="1.0" encoding="UTF-8"?>
    <wsdl:definitions name="MyFirstService"
        xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.talend.org/service/"
        targetNamespace="http://www.talend.org/service/">
    
        <wsdl:types>
            <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                targetNamespace="http://www.talend.org/service/">
                <xsd:element name="InputMessage">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="Get_BWPM_Users">
                                <xsd:complexType>
                                    <xsd:sequence>
                                        <xsd:element name="UserName" type="xsd:string" />
                                        <xsd:element name="LastLoginYM" type="xsd:string" />
                                    </xsd:sequence>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
                <xsd:element name="OutputMessage">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="BWPM_User" minOccurs="0" maxOccurs="unbounded">
                                <xsd:complexType>
                                    <xsd:sequence>
                                        <xsd:element name="UserName" type="xsd:string" />
                                        <xsd:element name="LastLoginDate" type="xsd:string" />
                                    </xsd:sequence>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>
            </xsd:schema>
        </wsdl:types>
    
        <wsdl:message name="getDataRequest">
            <wsdl:part name="parameters" element="tns:InputMessage"></wsdl:part>
        </wsdl:message>
        <wsdl:message name="getDataResponse">
            <wsdl:part name="parameters" element="tns:OutputMessage"></wsdl:part>
        </wsdl:message>
    
        <wsdl:message name="getQABWPMUsersRequest">
            <wsdl:part name="parameters" element="tns:getQABWPMUsers"></wsdl:part>
        </wsdl:message>
        <wsdl:message name="getQABWPMUsersResponse">
            <wsdl:part name="parameters" element="tns:getQABWPMUsersResponse"></wsdl:part>
        </wsdl:message>
        <wsdl:portType name="MyFirstServicePortType">
            <wsdl:operation name="getData">
                <wsdl:input message="tns:getDataRequest"></wsdl:input>
                <wsdl:output message="tns:getDataResponse"></wsdl:output>
            </wsdl:operation>
        </wsdl:portType>
    
        <wsdl:binding name="MyFirstServiceBinding" type="tns:MyFirstServicePortType">
            <soap:binding style="document"
                transport="http://schemas.xmlsoap.org/soap/http" />
            <wsdl:operation name="getData">
                <soap:operation soapAction="http://www.talend.org/service/getData" />
                <wsdl:input>
                    <soap:body use="literal" />
                </wsdl:input>
                <wsdl:output>
                    <soap:body use="literal" />
                </wsdl:output>
            </wsdl:operation>
        </wsdl:binding>
    
        <wsdl:service name="MyFirstService">
            <wsdl:port name="MyFirstServicePort" binding="tns:MyFirstServiceBinding">
                <soap:address location="http://localhost:8090/services/MyFirstService" />
            </wsdl:port>
        </wsdl:service>
    </wsdl:definitions>

    2、实现方法调用的Job

    注:这个Job需要以tESBProviderRequest开头,以tESBProviderResponse结尾

          另外当tMSSqlInput取数为空时,就不会执行后面的tESBProviderResponse,导致调用返回错误信息,所以在tMSSqlInput处加了一个Run if(判断条件为:(Integer)globalMap.get("tMSSqlInput_1_NB_LINE") == 0),让查询数据为空时走另外的流程来返回tESBProviderResponse,这样查询没有结果就不会返回错误信息了!

    3、Service加入Job

    这样Webservice基本完成!

  • 相关阅读:
    Ubuntu格式化分区时的一个小错误
    VS 2013中的新特性browser link
    回车登录,兼容
    ASP.NET MVC 站点设置.html 为起始页
    WebBrowser 禁用右键
    C# 获取时间差(几天前,几小时前,几分钟前,几秒前)
    JavaScrip操作Cookie
    JS生成GUID算法
    老李推荐: 第3章2节《MonkeyRunner源码剖析》脚本编写示例: MonkeyDevice API使用示例 4
    老李推荐: 第3章2节《MonkeyRunner源码剖析》脚本编写示例: MonkeyDevice API使用示例 3
  • 原文地址:https://www.cnblogs.com/angusyang/p/6437260.html
Copyright © 2020-2023  润新知