zoukankan      html  css  js  c++  java
  • 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基本完成!

  • 相关阅读:
    企业如何才能“勾搭”上服务网格技术?
    行云创新:云原生加速企业释放数据价值
    行云创新:后疫情时代,云原生为酒店数字化转型破局
    行云创新CEO马洪喜荣获“2021杰出质造人物奖”
    SolarMesh发布 v1.6.1版本,再不来体验就......
    什么是云原生?如何建设云原生平台?
    行云创新联合上汽乘用车打造云原生技术平台,加快实现数字化转型
    五分钟搭建你的第一个区块链应用
    mysql 存储过程
    MySQL-binlog日志格式 binlog_format三种模式详解
  • 原文地址:https://www.cnblogs.com/angusyang/p/6437260.html
Copyright © 2011-2022 走看看