k3 Cloud webservice json PHP 调用问题
金蝶云社区-云小爱
云小爱
0人赞赏了该文章 1,984次浏览 未经作者许可,禁止转载编辑于2014年12月31日 19:29:18

做了一个小程序测试通过 PHP 调用 JSON.
basic auth 没有问题,
web service 发布没有问题

连接没问题
cookie 没问题

但是, 返回 ctx == null 的错误。

{"ErrorCode":"Exception","Message":"{ctx == null}","StackTrace":"[PUR_Requisition_View: 2014/12/31 11:15:11]:\n[REQUEST: {CreateOrgId:0,Number:CGSQ000042,Id:}]System.Exception: {ctx == null}

[code]RestClient Object
(
[options] => Array
(
[headers] => Array
(
)

[parameters] => Array
(
[CreateOrgId] => 0
[Number] => CGSQ000042
[Id] =>
)

[curl_options] => Array
(
)

[user_agent] => PHP RestClient/0.1.2
[base_url] => 192.168.50.178
[format] =>
[format_regex] => /(\w+)\/(\w+)(;[.+])?/
[decoders] => Array
(
[json] => json_decode
[php] => unserialize
)

[username] => administrator
[password] => 888888
[_method] => GET
)

[handle] => Resource id #81
[response] => {"ResponseStatus":{"ErrorCode":"Exception","Message":"{ctx == null}","StackTrace":"[PUR_Requisition_View: 2014/12/31 11:15:11]:\n[REQUEST: {CreateOrgId:0,Number:CGSQ000042,Id:}]System.Exception: {ctx == null}\r\n at Kingdee.BOS.Contracts.ServiceFactory.GetService[T](Context ctx)\r\n at Kingdee.BOS.ServiceHelper.MetaDataServiceHelper.Load(Context ctx, String id, Boolean bRuntime)\r\n at Kingdee.BOS.ServiceInterface.FormServiceController.FormControllerProxy..ctor(Context ctx, String fid, OperationStatus status)\r\n at Kingdee.BOS.ServiceInterface.FormServiceController.<>c__DisplayClass3.b__2()\r\n at Kingdee.BOS.DataEntity.Metadata.Service.MemoryCache`1.<>c__DisplayClass1.b__0(String k)\r\n at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)\r\n at Kingdee.BOS.ServiceInterface.FormServiceController.Invoke(Object session, Object request)\r\n at Kingdee.BOS.Core.DynamicService.DynamicServiceModel.Invoke(Object session, Object request)\r\n at ServiceStack.ServiceInterface.ServiceBase`1.Execute(TRequest request) in d:\\01Code\\K3Cloud\\Workshop\\K3Cloud BOS\\OpenSourceLib\\ServiceStack\\ServiceStack.ServiceInterface\\ServiceBase.cs:line 228","IsSuccess":false,"Errors":[]}}
[headers] => stdClass Object
(
[cache_control] => private
[content_type] => application/json; charset=utf-8
[server] => Microsoft-IIS/7.5
[x_powered_by] => Array
(
[0] => ServiceStack/3.933 Win32NT/.NET
[1] => ASP.NET
)

[access_control_allow_origin] => *
[access_control_allow_methods] => GET, POST, PUT, DELETE, OPTIONS
[x_aspnet_version] => 4.0.30319
[set_cookie] => Array
(
[0] => ss-id=sLG5PeIJzEOospfGYFCcAg==; path=/
[1] => ss-pid=jrFtJZwOwEa+2hvtouGRwA==; expires=Sun, 31-Dec-2034 10:42:44 GMT; path=/
[2] => X-UAId=52; expires=Sun, 31-Dec-2034 10:42:44 GMT; path=/
)

[date] => Wed, 31 Dec 2014 11:15:11 GMT
[content_length] => 1265
)

[info] => stdClass Object
(
[url] =>192.168.50.178/K3CloudServiceInterface/json/syncreply/PUR_Requisition_View?CreateOrgId=0&Number=CGSQ000042&Id=
[content_type] => application/json; charset=utf-8
[http_code] => 500
[header_size] => 591
[request_size] => 234
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.078
[namelookup_time] => 0
[connect_time] => 0.015
[pretransfer_time] => 0.015
[size_upload] => 0
[size_download] => 1265
[speed_download] => 16217
[speed_upload] => 0
[download_content_length] => 1265
[upload_content_length] => 0
[starttransfer_time] => 0.078
[redirect_time] => 0
[certinfo] => Array
(
)

[redirect_url] =>
)

[error] =>
[decoded_response] =>
[iterator_positon:RestClient:private] =>
[url] => 192.168.50.178/K3CloudServiceInterface/json/syncreply/PUR_Requisition_View?CreateOrgId=0&Number=CGSQ000042&Id=
)[/code]

========================================
如果在浏览器中先连一次
192.168.50.178/K3CloudServiceInterface/json/syncreply/PUR_Requisition_View

感觉像是激活一下, 再通过 php restful client 就能够获得希望的结果, 比如

[code] [response] => {"Result":{"FID":100009,"FBillNo":"FO00000008","FForeOrgId":{"FOrgID":0,"FNUMBER":"101.2","FNAME":"\u603B\u88C5\u4E8B\u4E1A\u90E8"},"FBillTypeID":{"FNumber":"YCD01_SYS","FName":"\u666E\u901A\u9884\u6D4B\u5355"},"FDate":"\/Date(1419944400000+1100)\/","FDocumentStatus":"C","FDescription":"","FCreatorId":{"FUserID":0},"FCreateDate":"\/Date(1419989823000+1100)\/","FModifyDate":"\/Date(1419989847000+1100)\/","FApproverId":{"FUserID":0,"FName":"zuyi Wang"},"FModifierId":{"FUserID":0},"FApproveDate":"\/Date(1419992160950+1100)\/","FCancelStatus":"A","PLN_FORECAST__FEntity":[{"FEntryID":100013,"FMaterialID":{"FMATERIALID":0,"FNumber":"1000003"},"FUnitID":{"FUNITID":0,"FNumber":"Pcs","FName":"Pcs","FPrecision":0},"FQty":10.0000000000,"FStartDate":"\/Date(1419944400000+1100)\/","FEndDate":"\/Date(1419944400000+1100)\/","FCloseStatus":"A","FMtoNo":" ","FBaseUnitID":{"FUNITID":0,"FNumber":"Pcs","FName":"Pcs","FPrecision":0},"FBaseQty":10.0000000000,"FBaseOrderQty":0,"FBaseWriteOffQty":0,"FReserveType":"1","FPriority":0,"FWriteOffQty":0,"FOrderQty":0,"FRemark":"","PLN_FORECAST__FEntity_Link":[]}]}}[/code]