如何确定WSDL操作的输入参数的正确格式

时间:2016-03-31 09:18:10

标签: php web-services wsdl

我对所有SOAP / WSDL内容非常非常新,所以我必须使用正确的技术术语来询问非常基本的内容。如果是这样,请原谅。

我被同事提供了一个WSDL网址,我需要使用nuSOAP库调用该网络服务。

他还给了我一个XML - 我不知道如何处理它

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://oracle.com/determinations/server/12.2.1/rulebase/assess/types">
   <soapenv:Header/>
   <soapenv:Body>
      <typ:assess-request>
         <typ:global-instance>
            <!--Zero or more repetitions:-->
             <typ:attribute id="transaction_Amount" outcome-style="value-only"/>
             <typ:attribute id="line_Items" outcome-style="value-only"/>
             <typ:attribute id="requred_Documents" outcome-style="value-only"/>
            <typ:attribute id="transaction_Type">
               <!--You have a CHOICE of the next 8 items at this level-->
               <typ:text-val>Address Change</typ:text-val>
            </typ:attribute>
            <!--Zero or more repetitions:-->

         </typ:global-instance>
      </typ:assess-request>
   </soapenv:Body>
</soapenv:Envelope>

经过一段时间的研究,我发现它与“操作”和输入参数有关。所以我构建了一段看起来像这样的代码:

$client = new nusoap_client($url, "wsdl");
$error  = $client->getError();       
// I do not see the below message so I assume the connection was a success
if ($error) {
    echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}
$params = array(
    'global-instance' => "attribute"
);

$result = $client->call("Assess", array("assess-request"=>$params));
if ($client->fault) {
  echo "<h2>Fault</h2><pre>";
  print_r($result);
  echo "</pre>";
} else {
  $error = $client->getError();
  if ($error) {
    echo "<h2>Error</h2><pre>" . $error . "</pre>";
  } else {
    echo "<h2>Main</h2>";
    echo '<pre>';
    print_r($result);
    echo '</pre>';
  }
}

当我运行此代码时,我得到了

Array
(
    [faultcode] => SOAP-ENV:Client
    [faultstring] => Invalid element. Expected: global-instance. Actual: 
    [detail] => Array
        (
            [error-response] => Array
                (
                    [code] => com.oracle.determinations.server.exceptions.InvalidRequestException
                    [message] => Invalid element. Expected: global-instance. Actual: 
                )

        )

)

这让我相信我不是以正确的格式提供输入,但无法确定预期的格式是什么。在这方面有任何帮助吗?

编辑:如果有帮助,以下是我在浏览器中打开$ url时显示的WSDL部分

<wsdl:operation name="Assess">
   <wsdl:input message="typ:AssessRequest"/>
   <wsdl:output message="typ:AssessResponse"/>
</wsdl:operation>
<xsd:complexType name="AssessRequest">
  <xsd:annotation>
    <xsd:documentation>An assess-request contains an optional config node and a mandatory global-instance node.</xsd:documentation>
  </xsd:annotation>
  <xsd:sequence>
    <xsd:element name="config" type="AssessmentConfiguration" minOccurs="0">
      <xsd:annotation>
        <xsd:documentation>Options that control how the data provided to the assess operation should be processed, and how the response should be constructed.</xsd:documentation>
      </xsd:annotation>
    </xsd:element>
    <xsd:element name="global-instance" type="GlobalInstanceType">
      <xsd:annotation>
        <xsd:documentation>Input data on which to perform the assessment, using the policy model deployed at the service URL</xsd:documentation>
      </xsd:annotation>
    </xsd:element>
  </xsd:sequence>
</xsd:complexType>

1 个答案:

答案 0 :(得分:0)

你的陈述“这让我相信我没有以正确的格式提供输入”让我失望。此时您需要的是使用nuSOAP和PHP的教程。所以可能不是那个地方。更像是PHP NuSOAP TutorialWorking with PHP NuSOAP