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



我对所有SOAP/WSDL的东西都非常非常陌生,所以我一定在问一些非常基本的问题,或者没有使用正确的技术术语。如果是这样的话,请原谅。

一位同事向我提供了一个WSDL url,我需要使用nuSOAP库调用该Web服务。

他还给了我一个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>

你说的"这让我相信我没有以正确的格式提供输入"让我很反感。现在你需要的是使用nuSOAP和PHP的教程。SO可能不是这样的地方。更像PHP NuSOAP教程或使用PHP NuSOAP

最新更新