tousif tousif - 1 year ago 81
PHP Question

Using PFC shipping API in PHP

I am trying to use pfc shippiong api

I am trying to run the simple getCountry method, the first one on that page.
You can also find it working on this page
Just use the key pfc123456789 and hit search

My problem is that their example on the tutorial in the first link is for .Net and I know php only and integrating this in php

According to their tutorial

First step:In your own,add web quotation,Provide the API service website address offered by PFC. Be assumed to be:""

Second step:Initialization,then use the method,can obtain the data
pfc.pfcwebservice p=new pfc.pfcwebservice();
string result = p.getCountry(secretkey);

I am using curl for php
$curl = curl_init();
curl_setopt_array($curl, array(
secretkey => '2add5e13-3b85-45a9-9fcc-4b739de2b1b784342'

$resp = curl_exec($curl);
$r = mb_convert_encoding($resp,'ISO-8859-1','utf-8');


But no success.
But getting the following error

[InvalidOperationException: 因 URL 意外地以“/getCountry”结束,请求格式无法识别。]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(Type type, HttpContext context, HttpRequest request, HttpResponse response) +489333
System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext context, String verb, String url, String filePath) +212
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext context, String requestType, String url, String pathTranslated) +47
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +346
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

I don't understand .Net error

Any help would be highly appreciated.

Answer Source

I solved the issue by moving from CURL to SOAP, as pointed by Ryan above in the comments. We need to use SOAP to connect to .net 'asmx' services

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download