无法使用服务器上的Script Mediator转换JSON响应

时间:2014-10-30 16:14:34

标签: javascript arrays wso2 wso2esb

所有

我正在使用脚本中介将JSON响应转换为我想要的格式这个脚本中介在本地使用虚拟数据工作正常,但是当我将js移动到服务器时,它无法解析XML输出,因为它在当地的电脑做过。

请在下面找到详细信息。

终端系统的XML输出:

<xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <getMyClsScheduleResponse xmlns="http://<HostName>/schemas/getMyClsScheduleResponse.v1" xsi:schemaLocation="http://mais.he.umich.edu/schemas/getMyClsScheduleResponse.v1 http://<HostName>/PSIGW/PSCOnnection/getMyClsScheduleResponse.v1.xsd"> <RegisteredClass> <ClassNumber>10757</ClassNumber> <SubjectCode>AAS</SubjectCode> <CatalogNumber>510</CatalogNumber> ..... .... ... <Instructor> <InstructorName>Lyke-Whiting,Lynn</InstructorName> <LastName>Lyke-Whiting</LastName> <FirstName>Lynn</FirstName> <Uniqname>LYNNW</Uniqname> <InstructorRole>Secondary Instructor</InstructorRole> </Instructor> </RegisteredClass> </getMyClsScheduleResponse> </soapenv:Body> </soapenv:Envelope>

Json回复: "getMyClsScheduleResponse": { "@schemaLocation": "http://<HostName>/schemas/getMyClsScheduleResponse.v1 http://<HostName>/PSIGW/PSConnection/getMyClsScheduleResponse.v1.xsd", "RegisteredClass": [ { "ClassNumber": "10757", "SubjectCode": "AAS", "CatalogNumber": "510", "SectionNumber": "001", "SectionType": "IND", "SectionTypeDescr": "Independent Study", "SessionDescr": "Regular", "CourseDescr": "Supervised Research", "ClassTopic": "", "CreditHours": "1 - 6", "LMSURL": "", "Meeting": { "MeetingNumber": "1", "Days": "", "Times": "", "StartDate": "09/02/2014", "EndDate": "12/10/2014", "Location": "TBA", "TopicDescr": "" } }, { "ClassNumber": "30573", "SubjectCode": "ASIANLAN", "CatalogNumber": "100", "SectionNumber": "001", "SectionType": "REC", "SectionTypeDescr": "Recitation", "SessionDescr": "Regular", "CourseDescr": "Acc Elem Chinese", "ClassTopic": "", "CreditHours": "3", "LMSURL": "", "Meeting": { "MeetingNumber": "1", "Days": "MoWeFr", "Times": "9:00AM - 10:00AM", "StartDate": "09/02/2014", "EndDate": "12/10/2014", "Location": "706 BMT", "TopicDescr": "" }, "Instructor": [ { "InstructorName": "Emery,Lisa B", "LastName": "Emery", "FirstName": "Lisa", "Uniqname": "EMERYL", "InstructorRole": "Secondary Instructor" }, { "InstructorName": "Ford,Phyllis", "LastName": "Ford", "FirstName": "Phyllis", "Uniqname": "PAFORD", "InstructorRole": "Secondary Instructor" }, { "InstructorName": "Zhong,Yan", "LastName": "Zhong", "FirstName": "Yan", "Uniqname": "YANZHO", "InstructorRole": "Primary Instructor" } ] }, ] } }

Error log: TID: [0] [ESB] [2014-10-29 11:07:00,664] ERROR {org.apache.synapse.mediators.bsf.ScriptMediator} - The script engine returned an error executing the external js script : Value {name ='null', keyValue ='conf:/repository/esb/js/functions.js'} function transformPayload {org.apache.synapse.mediators.bsf.ScriptMediator} com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: TypeError: Cannot read property "RegisteredClass" from undefined (<Unknown source>#8) in <Unknown source> at line number 8 at com.sun.phobos.script.javascript.RhinoScriptEngine.invokeMethod(RhinoScriptEngine.java:259) at com.sun.phobos.script.javascript.RhinoScriptEngine.invokeFunction(RhinoScriptEngine.java:216) at org.apache.synapse.mediators.bsf.ScriptMediator.mediateWithExternalScript(ScriptMediator.java:271)

Script mediator code : function transformPayload(output) { payload = output.getPayloadJSON(); results = payload.getMyClsScheduleResponse.RegisteredClass; // Failing at this line.

当我尝试相同的数据时,本地不会发生同样的问题。有什么东西我不见了吗?

请告诉我。

由于 Kranthi

0 个答案:

没有答案