0

私は XML を扱うのは初めてで、PHP については中程度の理解があります。私は、このことを役に立たない応答を吐き出させようとして、複数のチュートリアルとビデオを調べました. 私は StackOverflow を使うのは好きではありません。なぜなら、私が人々に迷惑をかけているのか、自分の愚かさを誇示するつもりなのか (またはその両方) に神経質になるからです。しかし、私は必死です。

サービスを当社の Web サイトに統合する目的で、これらの 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 に答える