Talend Open Studio 将作业导出为 Web 服务并在没有 URL 参数的情况下调用它

Talend Open Studio exporting job as a webservice and calling it without URL parameters

我是第一次使用 Talend。我创建了一个 Talend Job 并将其导出为 AXIS 网络服务 war 文件。我已经将其部署在 tomcat 容器中。

现在,为了调用此 Web 服务,通过传递上下文参数的值,我需要构建一个 URL 并在其上设置值。

例如 URL 可能与此类似:

http://localhost:10080/StandardParcellor_0.1/services/StandardParcellor?method=runJob&arg1=--context_param%20DeliveryParcelMetadataFileLocation=C:\dev\temp\DMS\b2345678-2234-1234-1234-123456789123\a2345678-2234-1234-1234-123456789123\metadata.xml&arg2=--context_param%20WorkingPath=C:\dev\temp&arg3=--context_param%20DeliveryParcelID=db604807-8606-4107-8d3e-aff08c95db1c&arg4=--context_param%20PackageWorkingFolder=C:\dev\temp\DMS\b2345678-2234-1234-1234-123456789123\a2345678-2234-1234-1234-123456789123

如果您注意到我的 URL 非常长并且 URL 中的字符需要正确编码。这让我很伤心。即使它现在可以工作,它也可能会在以后根据 URL 的长度或我正在做的正确编码而中断。

我想知道并希望既然这是一个网络服务调用,尤其是一个 SOAP 调用,我们不能在 XML 中设置这些参数吗?创建一个肥皂信封并将其传递到网络服务中?甚至可能生成我可以从 WSDL 使用的 类 并以正确的方式调用 Web 服务,而不是这种看起来很糟糕的 URL.

不幸的是,据我所知,没有办法让生成的 war 可以用更漂亮的 URL 调用。

另一种选择是在其前面放置一个 Web 服务器,并通过重定向构建必要的 URL。

为了调用 Talend web 服务,您可以构造一个 post XML 并发送如下:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tal="http://talend.org">
   <soapenv:Header/>
   <soapenv:Body>
      <tal:args>
         <!--Zero or more repetitions:-->
         <tal:item>--context_param DeliveryParcelMetadataFileLocation=C:/dev/temp/DMS/b2345678-2234-1234-1234-123456789123/a2345678-2234-1234-1234-123456789123/metadata.xml</tal:item>
         <tal:item>--context_param WorkingPath=C:/dev/temp</tal:item>
         <tal:item>--context_param DeliveryParcelID=3a91335b-4789-48c5-b6dc-8fac9c20a8d0</tal:item>
         <tal:item>--context_param PackageWorkingFolder=C:/dev/temp/DMS/b2345678-2234-1234-1234-123456789123/a2345678-2234-1234-1234-123456789123</tal:item>
      </tal:args>
   </soapenv:Body>
</soapenv:Envelope>

以上似乎有效。希望有人能证实一下。

归功于:https://www.ntu.edu.sg/home/ehchua/programming/howto/Tomcat_HowTo.html#zz-2.5https://www.talendforge.org/forum/viewtopic.php?id=7423

假设您有一份名为 x 的工作并导出为 x_0.1.war.

将以下 html 文件放入 TOMCAT_HOME/webapps/yourapp 目录

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Ingest </title>
</head>
<body>
<h1>Please enter values for the job</h1>
<form action="http://localhost:8080/x_0.1/services/x" method="get">
<p>Method:<br><input name="method" type="text" size="30" maxlength="30" value="runJob"></p>
<p>arg1:<br><input name="arg1" type="text" size="60" maxlength="1000" value="--context_param context1=blahblahblah"></p>

<INPUT type="submit" name="submitJob" value="Start Job">  

</form>

</body>
</html>

arg1、arg2、arg3 等将作为上下文变量传递的参数