我该如何进行这个准确的肥皂呼叫?

发布于 2025-01-06 13:00:04 字数 2664 浏览 0 评论 0原文

首先,我是肥皂的初学者。

我正在尝试对服务进行肥皂调用,并获得了来自 talend 的工作示例。我需要的是在 PHP 中进行类似的调用。

talend 的输出如下(从 HTTP 请求中提取),

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <root>
      <request>
        <username>[email protected]</username>
        <password>md5sumlookalike</password>
        <webservice>GetCust</webservice>
        <refid>12343321</refid>
        <message>reserv#123</message>
      </request>
    </root>
  </soap:Body>
</soap:Envelope>

因此我编写了一些 PHP,因为它可以作为脚本语言,也可以从何处调用它。试图了解如何进行肥皂通话,我想出了这一点。

<?php
// Yes I know about the diffrent port issue here.  So I wgeted and stored it for use next to script
#   $soapClient = new SoapClient("http://123.123.123.123:8088/services", array("trace" => true)); 
    $soapClient = new SoapClient("wsdl", array("trace" => true)); 

    $error = 0; 
    try {   
        $info = $soapClient->__soapCall("invoke",
            array
            (
            new SoapParam("[email protected]", "username"),
            new SoapParam("md5sumish", "password"),
            new SoapParam("GetCust", "webservice"),
            new SoapParam("1234321", "refid"),
            new SoapParam("reserv#123", "message")

            )
        ); 
    } catch (SoapFault $fault) { 
        $error = 1; 
        echo 'ERROR: '.$fault->faultcode.'-'.$fault->faultstring; 
    } 

    if ($error == 0) { 
        print_r($output_headers);
        echo 'maybe it worked\n';
        unset($soapClient); 
    }   

?>

我最终在通过wireshark 的HTTP 请求中看到以下内容。服务器只是不知道该怎么办并且不响应。我不确定我需要从这里去哪里/去哪里。

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://talend.org/esb/service/job">
  <SOAP-ENV:Body>
    <ns1:invokeInput>[email protected]</ns1:invokeInput>
    <password>md5sumish</password>
    <webservice>GetCust</webservice>
    <refid>1234321</refid>
    <message>reserv#123</message>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

所以我要问的是如何摆脱 ns1:invokeInput 并使其成为用户名。同时将其余格式调整为一致,以便请求看起来像 talend 的输出?

To start off with, I am a beginner at soap.

I am trying to make a soap call to a service and was given a working sample that comes from talend. What I need is to make a similar call in PHP.

The output from talend is as follows, (extracted from the HTTP request)

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <root>
      <request>
        <username>[email protected]</username>
        <password>md5sumlookalike</password>
        <webservice>GetCust</webservice>
        <refid>12343321</refid>
        <message>reserv#123</message>
      </request>
    </root>
  </soap:Body>
</soap:Envelope>

So I wrote a little bit of PHP as it works as a scripting language as well for where it will be called from. Trying to understand how to make a soap call I came up with this bit.

<?php
// Yes I know about the diffrent port issue here.  So I wgeted and stored it for use next to script
#   $soapClient = new SoapClient("http://123.123.123.123:8088/services", array("trace" => true)); 
    $soapClient = new SoapClient("wsdl", array("trace" => true)); 

    $error = 0; 
    try {   
        $info = $soapClient->__soapCall("invoke",
            array
            (
            new SoapParam("[email protected]", "username"),
            new SoapParam("md5sumish", "password"),
            new SoapParam("GetCust", "webservice"),
            new SoapParam("1234321", "refid"),
            new SoapParam("reserv#123", "message")

            )
        ); 
    } catch (SoapFault $fault) { 
        $error = 1; 
        echo 'ERROR: '.$fault->faultcode.'-'.$fault->faultstring; 
    } 

    if ($error == 0) { 
        print_r($output_headers);
        echo 'maybe it worked\n';
        unset($soapClient); 
    }   

?>

I end up seeing the following in the HTTP request via wireshark. The server just does not know what to do with this and does not respond. I am unsure what/where I need to go from here.

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://talend.org/esb/service/job">
  <SOAP-ENV:Body>
    <ns1:invokeInput>[email protected]</ns1:invokeInput>
    <password>md5sumish</password>
    <webservice>GetCust</webservice>
    <refid>1234321</refid>
    <message>reserv#123</message>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

So I have to ask is how to get rid of the ns1:invokeInput and make it username. Along with bring the rest of the format into line so the request looks like the output from talend?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疾风者 2025-01-13 13:00:04

这是我在 php 中编写的一个工作小脚本,用于调用导出为soap 的 talend 教程服务:

//....
if (sizeof($_POST) > 0) {
    $name = $_POST['name'];
    $city = $_POST['city'];
    $client = new SoapClient("http://192.168.32.205:8080/DirectoryService/services/DirectoryService?wsdl", array( 'trace' => 1));

    $result = $client->runJob(array(
        '--context_param',
        'Name=' . $_POST['name'],
        '--context_param',
        'City=' . $_POST['city']
    ));
}
//...   

Talend 对于如何给出参数似乎非常“基本”。
使用这段代码,它工作得很好。

Here is a working little script I did in php to call a talend tutorial service exported as soap:

//....
if (sizeof($_POST) > 0) {
    $name = $_POST['name'];
    $city = $_POST['city'];
    $client = new SoapClient("http://192.168.32.205:8080/DirectoryService/services/DirectoryService?wsdl", array( 'trace' => 1));

    $result = $client->runJob(array(
        '--context_param',
        'Name=' . $_POST['name'],
        '--context_param',
        'City=' . $_POST['city']
    ));
}
//...   

Talend seems to be very "basic" regarding how parameters are given.
With this code it was working fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文