Reputation: 5525
My Client gave me URL for SOAP purpose, so I can send data directly to their server. and when I open the URL, it gives me this XML :
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="http://tempuri.org/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://tempuri.org/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="RegisterApplication">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="oEnt" type="tns:DataCustomer"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="DataCustomer">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="PartnerID" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="Datetime" type="s:dateTime"/>
<s:element minOccurs="0" maxOccurs="1" name="CustomerName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="EmailCustomer" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="CustomerAddress" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="CustomerNumber1" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="CustomerNumber2" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SubmissionID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ListingID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SellerName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SellerNumber" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="EmailSeller" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="SellerAddress" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Product" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="VehicleType" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Year" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="Funding" type="s:decimal"/>
<s:element minOccurs="0" maxOccurs="1" name="LinkIklan" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ZipCode" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="City" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Kelurahan" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Kecamatan" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="CustDateOfBirth" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="MonthlyIncome" type="s:decimal"/>
<s:element minOccurs="0" maxOccurs="1" name="Brand" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="Tenor" type="s:int"/>
<s:element minOccurs="1" maxOccurs="1" name="Installment" type="s:decimal"/>
<s:element minOccurs="0" maxOccurs="1" name="ImageIDCustomer" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="ImageStnkNoticePajak" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="RegisterApplicationResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="RegisterApplicationResult" type="tns:DataCustomerRespond"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="DataCustomerRespond">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Status" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Notes" type="s:string"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
<wsdl:message name="RegisterApplicationSoapIn">
<wsdl:part name="parameters" element="tns:RegisterApplication"/>
</wsdl:message>
<wsdl:message name="RegisterApplicationSoapOut">
<wsdl:part name="parameters" element="tns:RegisterApplicationResponse"/>
</wsdl:message>
<wsdl:portType name="APISoap">
<wsdl:operation name="RegisterApplication">
<wsdl:input message="tns:RegisterApplicationSoapIn"/>
<wsdl:output message="tns:RegisterApplicationSoapOut"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="APISoap" type="tns:APISoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RegisterApplication">
<soap:operation soapAction="http://tempuri.org/RegisterApplication" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="APISoap12" type="tns:APISoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="RegisterApplication">
<soap12:operation soapAction="http://tempuri.org/RegisterApplication" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="API">
<wsdl:port name="APISoap" binding="tns:APISoap">
<soap:address location="http://example.com/apidigital/api.asmx"/>
</wsdl:port>
<wsdl:port name="APISoap12" binding="tns:APISoap12">
<soap12:address location="http://example.com/apidigital/api.asmx"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
and here's my PHP code :
<?
$client = new SoapClient("http://example.com/api.asmx?wsdl");
$params = array ( "PartnerID" => "17000000",
"Datetime" => "2017-04-11T00:24:59",
"CustomerName" => "Robson",
"EmailCustomer" => "[email protected]",
"CustomerAddress" => "Somewhere On Earth",
"CustomerNumber1" => "08100000000",
"CustomerNumber2" => "08380000000",
"SubmissionID" => "KOM000000",
"ListingID" => "FB120374",
"SellerName" => "",
"SellerNumber" => "",
"EmailSeller" => "",
"SellerAddress" => "",
"Product" => "Motor",
"VehicleType" => "Honda",
"Year" => "1995",
"Funding" => "2000000",
"LinkIklan" => "www.example.com/21938",
"ZipCode" => "15322",
"City" => "Serpong",
"Kelurahan" => "Cisauk",
"Kecamatan" => "Sampora",
"CustDateOfBirth" => "1971-02-16",
"MonthlyIncome" => "9000000",
"Brand" => "Honda",
"Tenor" => "12",
"Installment" => "318500",
"ImageIDCustomer" => "https://example.com",
"ImageStnkNoticePajak" => "https://example.com" );
$response = $client->RegisterApplication($params);
print_r($response);
?>
my php always failed to submit the data to the server using SOAP. it always gives me this error :
stdClass Object
(
[RegisterApplicationResult] => stdClass Object
(
[Status] => 99
[Notes] => Object reference not set to an instance of an object.
)
)
did I miss something in my parameter? why PHP can't send the data inside array to SOAP server?
thank you
Upvotes: 0
Views: 83
Reputation: 760
You do not match the expected request.
The RegisterApplication
operation is waiting for a RegisterApplication
element as parameter which contains a oEnt
property which is of type DataCustomer
. So normally, you should have an array with the first key oEnt
which would point to your current array $params
containing all your customer data.
If you don't want to waste time, you should consider using a WSDL to php generator such as the PackageGenerator project which generates all the required classes in order to construct the request parameters, send the request then finally handle the response.
Upvotes: 1