I want to write a PHP code to send authentication and data to the web service. Please see the web service SOAP XML structure below:
This is a URL to access web API https://portal.xyzonline.com/API/ABCAPIServer.asmx?WSDL
I will really appreciate if you can help me to just write basic code.
This is what I am trying to do:
PHP Code
$client = new SoapClient("https://portal.xyzonline.com/API/ABCAPIServer.asmx?WSDL");
$params = array(
'addCaseReq' => array(
'DlcpmCase' => array(
'CaseID' => '1234',
'CustomerID' => '222',
'PatientFirst' => 'John'
),
'Auth' => array(
'AppName' => 'appname',
'UserName' => 'username',
'Password' => 'password'
)
)
);
try {
$responsetest = $client->AddCase(new SoapParam(array($params)));
} catch(SoapFault $fault) {
print_r($fault);
}
XML
<wsdl:types>
<s:schema>
<s:element name="AddCase">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="addCaseReq" type="tns:ABCAPIAddCaseRequest"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="ABCAPIAddCaseRequest">
<s:complexContent mixed="false">
<s:extension base="tns:ABCAPIRequest">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="AbcCase" type="tns:ABCCase"/>
</s:sequence>
</s:extension>
</s:complexContent>
</s:complexType>
<s:complexType name="ABCAPIRequest" abstract="true">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Auth" type="tns:ABCAPIAuthentication"/>
</s:sequence>
</s:complexType>
<s:complexType name="ABCAPIAuthentication">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="AppName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="UserName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Password" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="ABCCase">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="CaseID" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="CaseNumber" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="CustomerID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="PatientFirst" type="s:string"/>
</s:sequence>
</s:complexType>
</s:schema>
</wsdl:types>
Screenshot of WCFStorm
I am using WCFStorm and everything is working fine. Please see the screenshot: