duanfang5849 2015-01-30 13:15
浏览 57
已采纳

在PHP中使用PFC运输API

I am trying to use pfc shippiong api http://www.pfcexpress.com/webservice/EnAPIDoc.html

I am trying to run the simple getCountry method, the first one on that page. You can also find it working on this page http://bit.ly/1Lq4t6G 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

FOR .NET First step:In your own project:asp.net,add web quotation,Provide the API service website address offered by PFC. Be assumed to be:"http://pfcexpress.com/webservice/APIWebService.asmx"

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( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => 'http://www.pfcexpress.com/webservice/APIWebService.asmx/getCountry', CURLOPT_POST => 1, CURLOPT_POSTFIELDS => array( secretkey => '2add5e13-3b85-45a9-9fcc-4b739de2b1b784342' ) ));

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

    curl_close($curl);  

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. Thanks.

  • 写回答

1条回答 默认 最新

  • dqqxkq4047 2017-08-28 06:42
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路