How should we start programming an interface to interface with an API with weak documentation?

We are trying to develop a web interface that interfaces with the SiteLink API (docs here). SiteLink is a service that allows for self-serve purchasing of storage units.

We know we need to create a form that captures the data for the payment processor and for SiteLink. We also know we need to be able to list what units are available for rent.

We are much more experienced with PHP than .net, and have interfaced with APIs using PHP in the past.

How should we start?

Thanks!
Harrison WalkerAsked:
Who is Participating?
 
Ray PaseurCommented:
Wow, it's scary that anybody would publish and API in 2014 that uses SOAP!  That's just technically incompetent.  But that aside, there is something you need to be aware of... PHP SOAP support is really bad, so I second the SOAPUI recommendation, if you're forced to use SOAP.  One of the PHP SOAP surprises that I have hit in the past: SOAP namespaces do not prevent variable name collisions.  This bug is over 5 years old and unfixed, implying that PHP does not consider SOAP to be a credible technology worth supporting.

Recommend that you contact the publishers of the API and find out if they have a RESTful interface.  The internet is littered with the rotting husks of failed SOAP projects, but I have never seen anyone who could not immediately understand and use a REST API.  If there is one, it will be easier to use than SOAP, I guarantee it!

Good luck with the project, ~Ray
0
 
Walter RitzelSenior Software EngineerCommented:
I would say reading the manual and following the instructions for PHP. I would assume there is some kind of component that given the WSDL would provide the available methods. But it is just my 2 cents.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
>I would say reading the manual and following the instructions for PHP. I would assume there is some kind of component that given the WSDL would provide the available methods

Walter, he is looking for an answer, not something you are guessing at.

Unfortunately, there are plenty of API's that have the most basic of documentation and there is nothing you can do about what they are providing.  In contrast, the soap api from Authorize.net http://developer.authorize.net/api/aim/ has pretty documentation, and SDK and code samples to get you started.  

Since this is not the case here you have to build your own. There is something that can generate php code for you https://www.wsdltophp.com/ and the github project to do it yourself https://github.com/wsdl2phpgenerator/wsdl2phpgenerator.  I have tried this and ended up going with my own as below.

 They have given the sample code for site information
echo '<p>Testing SiteLink...</p>';
define( 'SITELINK_URL', "https://api.smdservers.net/CCWs_3.5/CallCenterWs.asmx?WSDL");
define( 'SITELINK_CORP_CODE', "CCTST" );
define( 'SITELINK_LOC_CODE', "Demo" );
define( 'SITELINK_CORP_LOGIN', "Administrator" );
define( 'SITELINK_CORP_PASS', "Demo" );
$client = new SoapClient( SITELINK_URL );
$params->sCorpCode = SITELINK_CORP_CODE;
$params->sLocationCode = SITELINK_LOC_CODE;
$params->sCorpUserName = SITELINK_CORP_LOGIN;
$params->sCorpPassword = SITELINK_CORP_PASS;
try
{
 $units = $client->SiteInformation( $params );
 $result = $units->SiteInformationResult;
}
catch (Exception $e )
{
 die( 'Error: '.$e->getMessage().'<br>'.$e );
}
echo htmlentities( $result->any );

Open in new window


The API xml documentation can be found at http://api.smdservers.net/CCWs_3.5/CallCenterWs.asmx with this specific method http://api.smdservers.net/CCWs_3.5/CallCenterWs.asmx?op=SiteInformation

You can see how that matches up with the xml
POST /CCWs_3.5/CallCenterWs.asmx HTTP/1.1
Host: api.smdservers.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/CallCenterWs/CallCenterWs/SiteInformation"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SiteInformation xmlns="http://tempuri.org/CallCenterWs/CallCenterWs">
      <sCorpCode>string</sCorpCode>
      <sLocationCode>string</sLocationCode>
      <sCorpUserName>string</sCorpUserName>
      <sCorpPassword>string</sCorpPassword>
    </SiteInformation>
  </soap:Body>
</soap:Envelope>

Open in new window


Then the response is parsing the xml that gets returned.
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <SiteInformationResponse xmlns="http://tempuri.org/CallCenterWs/CallCenterWs">
      <SiteInformationResult>
        <xsd:schema>schema</xsd:schema>xml</SiteInformationResult>
    </SiteInformationResponse>
  </soap:Body>
</soap:Envelope>

Open in new window


If you can follow that, the rest should start working.  I have just had to deal with a very similar API with similar documentation so I understand where you are coming from.

Since they have sample code for this one method, give this a try and see what errors or response you get.
0
 
LajuanTaylorCommented:
@hdw632 -  To save your Team some time with testing the API, you can use the free version of SOAP UI. Just hover over the "Downloads" link on the following page: http://www.soapui.org/?_ga=1.177816039.396142226.1428332034

I used the URL that was provided by @Scott Fell to create a sample test suite in a few minutes. See the attached screen shots. Please note, everything still worked fine even though I was using an older version of SOAP UI. I labeled the graphics Step 1 thru 6.
Step1.png
Step2.png
Step3.png
Step4.png
Step5.png
Step6.png
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.