0

我是使用 XML 的新手,我对 PHP 有中等程度的了解。我浏览了多个教程和视频,试图让这个东西吐出一个无济于事的回应。我不喜欢使用 StackOverflow,因为我很紧张,因为我要么打扰别人,要么展示我的愚蠢(或两者兼而有之),但我很绝望。

我从第三方收到了这些 XML 文件,目的是将该服务集成到我们公司的网站中。在我这样做之前,我需要让事情在本地工作,我似乎无法弄清楚。

这是我提供的 WSDL (canx_antu-2.0.wsdl):

<?xml version="1.0" encoding="UTF-8" ?>
<wsdl:definitions xmlns:cnx="http://www.cannex.com"
                  xmlns:cws="http://www.cannex.com/canx_antu/"
                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                  name="canx_antu" 
                  targetNamespace="http://www.cannex.com/canx_antu/">

  <wsdl:documentation>
    This file and any supporting xsd schemas are located at "http://localhost:8080/CANX/wsdl"
  </wsdl:documentation>

<!-- Data types used by the operation -->
  <wsdl:types>
    <xsd:schema targetNamespace="http://www.cannex.com/canx_antu/">
      <xsd:import schemaLocation="req_antu_type-2.0.xsd" namespace="http://www.cannex.com" /> <!-- Data types used for the request -->
      <xsd:element type="cnx:req_antu_type" name="antu_request" />
    </xsd:schema>  
    <xsd:schema targetNamespace="http://www.cannex.com/canx_antu/">
      <xsd:import schemaLocation="resp_antu_type-2.0.xsd" namespace="http://www.cannex.com" /> <!-- Data types used for the response -->
      <xsd:element type="cnx:resp_antu_type" name="antu_response" />
    </xsd:schema>  
  </wsdl:types>

<!-- Definition of the data being communicated -->
  <wsdl:message name="canx_antu_request"> <!-- Input/request name -->
    <wsdl:part element="cws:antu_request" name="parameters" /> <!-- Data elements of the request -->
  </wsdl:message>
  <wsdl:message name="canx_antu_response"> <!-- Output/response name -->
    <wsdl:part element="cws:antu_response" name="parameters" /> <!-- Data elements of the response -->
  </wsdl:message>

<!-- Set of operations -->
  <wsdl:portType name="canx_antu_porttype"> <!-- Web service name -->
    <wsdl:operation name="canx_antu_operation"> <!-- Operation name -->
      <wsdl:input message="cws:canx_antu_request" /> <!-- Input/request operation -->
      <wsdl:output message="cws:canx_antu_response" /> <!-- Output/response operation -->
    </wsdl:operation>
  </wsdl:portType>

<!-- Data format used for the operation --> 
  <wsdl:binding name="canx_antu_binding" type="cws:canx_antu_porttype"> <!-- Type points to port above under operations -->
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="canx_antu_operation">
      <soap:operation soapAction="http://www.cannex.com/canx_antu/canx_antu_operation" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>

  <wsdl:service name="canx_antu_service">
    <wsdl:port binding="cws:canx_antu_binding" name="canx_antu_binding">
      <soap:address location="http://localhost:8888/canx_antu/soap_antu-2.0.xml" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

请求(req_antu_type-2.0.xsd):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.cannex.com" xmlns:cnx="http://www.cannex.com"
    elementFormDefault="qualified">

    <xsd:include schemaLocation="antu_types-2.0.xsd" />

    <xsd:complexType name="req_antu_type">
        <xsd:sequence>
            <xsd:element type="xsd:string" name="logon_id" />
            <xsd:element type="xsd:string" name="user_id" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="app" default="CANX" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="transaction_id" 
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="cost_basis" />
            <xsd:element type="xsd:date" name="birth_date" />
            <xsd:element type="xsd:date" name="joint_birth_date" 
                minOccurs="0" />
            <xsd:element type="xsd:date" name="owner_birth_date"
                minOccurs="0" />
            <xsd:element type="xsd:date" name="premium_purchase_date" />
            <xsd:element type="xsd:date" name="first_payment_date" />
            <xsd:element type="cnx:fund_type_cd_type" name="fund_type_cd" />
            <xsd:element type="cnx:return_of_premium_cd_type" name="return_of_premium_cd" />
            <xsd:element type="cnx:guarantee_cd_type" name="guarantee_cd"
                minOccurs="0" />
            <xsd:element type="cnx:year_0_99_type" name="guarantee_year"
                minOccurs="0" />
            <xsd:element type="cnx:month_0_11_type" name="guarantee_month"
                minOccurs="0" />
            <xsd:element type="cnx:yn_type" name="indicate_impaired"
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="income"
                minOccurs="0" />
            <xsd:element type="cnx:rate_5_3_type" name="index_rate"
                minOccurs="0" />
            <xsd:element type="cnx:index_type_cd_type" name="index_type_cd" />
            <xsd:element type="cnx:joint_type_cd_type" name="joint_type_cd" />
            <xsd:element type="xsd:string" name="name" />
            <xsd:element type="xsd:string" name="joint_name" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="owner" 
                minOccurs="0" />
            <xsd:element type="cnx:yn_type" name="is_owner_primary" />
            <xsd:element type="cnx:payment_frequency_cd_type" name="payment_frequency_cd" />
            <xsd:element type="cnx:rate_6_3_type" name="percent"
                minOccurs="0" />
            <xsd:element type="cnx:rate_6_3_type" name="joint_percent"
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="premium" />
            <xsd:element type="xsd:string" name="prepared_by"
                minOccurs="0" />
            <xsd:element type="cnx:state_cd_type" name="region_cd" />
            <xsd:element type="cnx:state_cd_type" name="region_issued_cd"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="request_description" 
                minOccurs="0" />
            <xsd:element type="cnx:gender_cd_type" name="gender_cd" />
            <xsd:element type="cnx:gender_cd_type" name="joint_gender_cd"
                minOccurs="0" />
            <xsd:element type="cnx:gender_cd_type" name="owner_gender_cd"
                minOccurs="0" />
            <xsd:element type="cnx:yn_type" name="is_spouse"
                minOccurs="0" />
            <xsd:element type="cnx:survey_type_cd_type" name="survey_type_cd" />
            <xsd:element type="cnx:year_0_99_type" name="temporary_year"
                minOccurs="0" />
            <xsd:element type="cnx:month_0_11_type" name="temporary_month"
                minOccurs="0" />
            <xsd:element type="cnx:parameter_set_cd_type" name="parameter_set_cd"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="institution_id"
                minOccurs="0" />
            <xsd:element type="xsd:date" name="base_date" 
                minOccurs="0" />
            <xsd:element type="xsd:date" name="moment_date"
                minOccurs="0" />
            <xsd:element type="xsd:time" name="moment_time"
                minOccurs="0" />
            <xsd:element type="cnx:custom_type" name="custom"
                minOccurs="0" maxOccurs="10" />
            <xsd:element type="xsd:string" name="filter_customer"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="filter_institution_id"
                minOccurs="0" />
            <xsd:element type="cnx:trace_level_cd_type" name="trace_level_cd"
                minOccurs="0" />
            <xsd:element type="cnx:output_option_cd_type" name="output_option_cd"
                minOccurs="0" />
            <xsd:element type="xsd:decimal" name="return_of_premium_rate"
                minOccurs="0" />
            <xsd:element type="cnx:ratings_company_cd_type" name="ratings_company_cd"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="ratings_cd"
                minOccurs="0" />
            <xsd:element type="cnx:yn_type" name="exclude_not_rated"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="unique_c" 
                minOccurs="0" />
            <xsd:element type="cnx:unique_d_type" name="unique_d"
                minOccurs="0" maxOccurs="20" />
            <xsd:element type="cnx:yn_type" name="is_test" />
        </xsd:sequence>
        <xsd:attribute type="xsd:string" name="version" fixed="2.0" />
    </xsd:complexType>

</xsd:schema>

和响应(resp_antu_type-2.0.xsd):

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.cannex.com" xmlns:cnx="http://www.cannex.com"
    elementFormDefault="qualified">

    <xsd:include schemaLocation="req_antu_type-2.0.xsd" />

    <xsd:complexType name="resp_antu_type">
        <xsd:sequence>
            <xsd:element type="xsd:date" name="run_date" />
            <xsd:element type="xsd:time" name="run_time" />
            <xsd:element type="xsd:string" name="transaction_id" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="request_no"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="single_institution_id"
                minOccurs="0" />
            <xsd:element type="cnx:req_antu_type" name="antu_request"
                minOccurs="0" />
            <xsd:element type="cnx:survey_notes_type" name="survey_notes"
                minOccurs="0" />
            <xsd:element type="cnx:carrier_type" name="carrier"
                minOccurs="0" maxOccurs="unbounded" />
            <xsd:element type="cnx:error_type" name="error"
                minOccurs="0" />
        </xsd:sequence>
        <xsd:attribute type="xsd:string" name="version" fixed="2.0" />
    </xsd:complexType>

    <xsd:complexType name="carrier_type">
        <xsd:sequence>
            <xsd:element type="xsd:string" name="institution_id" />
            <xsd:element type="xsd:string" name="naic" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="institution_name" />
            <xsd:element type="cnx:quote_type" name="quote"
                maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="error_type">
        <xsd:sequence>
            <xsd:element type="xsd:string" name="error_level" />
            <xsd:element type="xsd:string" name="error_cd" />
            <xsd:element type="xsd:string" name="error_message"
                minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:simpleType name="expiry_cd_type">
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="G|NB|NG|" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:complexType name="name_value_type">
      <xsd:simpleContent>
         <xsd:extension base="xsd:string">
            <xsd:attribute type="xsd:string" name="name" use="required" />
         </xsd:extension>
      </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="notes_type">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element type="cnx:note_type" name="note" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="note_type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute type="xsd:string" name="note_id" use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

    <xsd:complexType name="quote_type">
        <xsd:sequence>
            <xsd:element type="cnx:yn_type" name="return_of_premium" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="set" 
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="premium" 
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="income" 
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="tax_amount"
                minOccurs="0" />
            <xsd:element type="cnx:rate_5_3_type" name="return_of_premium_rate"
                minOccurs="0" />
            <xsd:element type="cnx:expiry_cd_type" name="expiry_cd"
                minOccurs="0" />
            <xsd:element type="xsd:date" name="expiry_date"
                minOccurs="0" />
            <xsd:element type="xsd:time" name="expiry_time"
                minOccurs="0" />
            <xsd:element type="xsd:string" name="rating" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="set_unique" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="cusip" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="isin" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="product_name" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="illustration_id" 
                minOccurs="0" />
            <xsd:element type="xsd:string" name="illustration_pdf" 
                minOccurs="0" />
            <xsd:element type="cnx:request_overrides_type" name="request_overrides"
                minOccurs="0" />
            <xsd:element type="cnx:name_value_type" name="name_value" 
                minOccurs="0" maxOccurs="unbounded"/>
            <xsd:element type="cnx:notes_type" name="notes" 
                minOccurs="0" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="request_overrides_type">
        <xsd:sequence>
            <xsd:element type="cnx:rate_6_3_type" name="percent"
                minOccurs="0" />
            <xsd:element type="cnx:rate_6_3_type" name="joint_percent"
                minOccurs="0" />
            <xsd:element type="cnx:rate_5_3_type" name="index_rate"
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="amount"
                minOccurs="0" />
            <xsd:element type="cnx:money_10_2_type" name="cost_basis"
                minOccurs="0" />
            <xsd:element type="xsd:date" name="first_payment_date"
                minOccurs="0" />
            <xsd:element type="xsd:date" name="premium_payment_date"
                minOccurs="0" />
            <xsd:element type="cnx:guarantee_cd_type" name="guarantee_cd"
                minOccurs="0" />
            <xsd:element type="cnx:year_0_99_type" name="guarantee_year"
                minOccurs="0" />
            <xsd:element type="cnx:month_0_11_type" name="guarantee_month"
                minOccurs="0" />
            <xsd:element type="cnx:year_0_99_type" name="temporary_year"
                minOccurs="0" />
            <xsd:element type="cnx:month_0_11_type" name="temporary_month"
                minOccurs="0" />
            <xsd:element type="cnx:yn_type" name="has_changed" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="survey_notes_type">
        <xsd:sequence maxOccurs="unbounded">
            <xsd:element type="cnx:survey_note_type" name="survey_note" />
        </xsd:sequence>
    </xsd:complexType>

    <xsd:complexType name="survey_note_type">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute type="xsd:string" name="survey_note_id"
                    use="required" />
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType>

</xsd:schema>

最后,这就是我的 PHP 中的内容。我只是试图通过所需的变量并吐出一个响应(index.php):

<?php

ini_set('soap.wsdl_cache_ttl', 1);

$path = "http://localhost:8888/canx_antu/canx_antu-2.0.wsdl";
$client = new SoapClient($path);

$result = $client->canx_antu_operation(array('logon_id' => 'CUST01',
                                                'cost_basis' => 100000.00,
                                                'birth_date' => '1944-12-30',
                                                'premium_purchase_date' => '2013-03-28',
                                                'first_payment_date' => '2013-04-28',
                                                'fund_type_cd' => 'N',
                                                'return_of_premium_cd' => 'GT',
                                                'index_type_cd' => 'N',
                                                'joint_type_cd' => 'N',
                                                'name' => 'Johnny Rocket',
                                                'is_owner_primary' => 'Y',
                                                'payment_frequency_cd' => 'M',
                                                'premium' => 100000.00,
                                                'region_cd' => 'CA',
                                                'gender_cd' => 'M',
                                                'survey_type_cd' => 'JL',
                                                'custom' => 1,
                                                'unique_d' => 5,
                                                'is_test' => 'N'));

$array = $result->antu_request;

var_dump($array);

echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";

?>

我得到的只是一个空白页。如果我不传递一个数组,我会得到 NULL 并且 REQUEST 或 RESPONSE 什么都没有显示(所以它显然不起作用,我只是不知道为什么)。

我很想得到一个直接的答案,但对于一些进一步的学习来说,一个正确的方向也是理想的。

4

1 回答 1

0

你可能想要一些类似的东西,

$result = $client->__soapcall('canx_antu_operation', array(
            'logon_id' => 'CUST01',
            'cost_basis' => 100000.00,
            'birth_date' => '1944-12-30',
            'premium_purchase_date' => '2013-03-28',
            'first_payment_date' => '2013-04-28',
            'fund_type_cd' => 'N',
            'return_of_premium_cd' => 'GT',
            'index_type_cd' => 'N',
            'joint_type_cd' => 'N',
            'name' => 'Johnny Rocket',
            'is_owner_primary' => 'Y',
            'payment_frequency_cd' => 'M',
            'premium' => 100000.00,
            'region_cd' => 'CA',
            'gender_cd' => 'M',
            'survey_type_cd' => 'JL',
            'custom' => 1,
            'unique_d' => 5,
            'is_test' => 'N'
        )
);
于 2013-10-09T15:21:00.280 回答