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

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

报告相同问题?

悬赏问题

  • ¥15 csmar数据进行spss描述性统计分析
  • ¥15 各位请问平行检验趋势图这样要怎么调整?说标准差差异太大了
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?