我正在尝试(非常努力)在 WSO2 EI611 中创建可以在 JSON 中调用的数据服务。但是当我将数据发布到服务时,我不知道要使用的 JSON 格式。尝试了很多格式,但我得到空错误。
提前致谢。
这是我的数据服务代码:
<data name="OAuthToken" serviceGroup="" serviceNamespace="">
<description/>
<config id="QT_DB">
<property name="org.wso2.ws.dataservice.user">wso2</property>
<property name="org.wso2.ws.dataservice.password">wso2</property>
<property name="org.wso2.ws.dataservice.protocol">jdbc:mysql://192.168.1.10:3306/QT_DB</property>
<property name="org.wso2.ws.dataservice.driver">com.mysql.jdbc.Driver</property>
</config>
<query id="AddNewToken" useConfig="QT_DB">
<sql>INSERT INTO QT_DB.OAUTH_TOKEN (ACCESS_TOKEN, TOKEN_TYPE, API_SERVER, CREATED, EXPIRES_IN, EXPIRATION, REFRESH_TOKEN) VALUES(:ACCESS_TOKEN, :TOKEN_TYPE, :API_SERVER, :CREATED, :EXPIRES_IN, DATE_ADD(:CREATED, INTERVAL :EXPIRES_IN SECOND), :REFRESH_TOKEN);
</sql>
<param name="ACCESS_TOKEN" sqlType="STRING" type="IN"/>
<param name="TOKEN_TYPE" sqlType="STRING" type="IN"/>
<param name="API_SERVER" sqlType="STRING" type="IN"/>
<param name="CREATED" sqlType="TIMESTAMP" type="IN"/>
<param name="EXPIRES_IN" sqlType="INTEGER" type="IN"/>
<param defaultValue="0" name="EXPIRATION" sqlType="INTEGER" type="IN"/>
<param name="REFRESH_TOKEN" sqlType="STRING" type="IN"/>
</query>
<query id="GetLastToken" useConfig="QT_DB">
<sql>SELECT CREATED,ACCESS_TOKEN, TOKEN_TYPE, API_SERVER, EXPIRES_IN, EXPIRATION, REFRESH_TOKEN FROM OAUTH_TOKEN WHERE CREATED = (SELECT MAX(CREATED) FROM OAUTH_TOKEN);</sql>
<result defaultNamespace="" element="OAUTH_TOKENS" rowName="OAUTH_TOKEN">
<element column="ACCESS_TOKEN" name="ACCESS_TOKEN" xsdType="xs:string"/>
<element column="TOKEN_TYPE" name="TOKEN_TYPE" xsdType="xs:string"/>
<element column="API_SERVER" name="API_SERVER" xsdType="xs:string"/>
<element column="CREATED" name="CREATED" xsdType="xs:dateTime"/>
<element column="EXPIRES_IN" name="EXPIRES_IN" xsdType="xs:integer"/>
<element column="EXPIRATION" name="EXPIRATION" xsdType="xs:dateTime"/>
<element column="REFRESH_TOKEN" name="REFRESH_TOKEN" xsdType="xs:string"/>
</result>
</query>
<operation returnRequestStatus="true" name="GetLastToken">
<call-query href="GetLastToken"/>
</operation>
<operation returnRequestStatus="true" name="AddNewToken">
<call-query href="AddNewToken">
<with-param name="ACCESS_TOKEN" query-param="ACCESS_TOKEN"/>
<with-param name="TOKEN_TYPE" query-param="TOKEN_TYPE"/>
<with-param name="API_SERVER" query-param="API_SERVER"/>
<with-param name="CREATED" query-param="CREATED"/>
<with-param name="EXPIRES_IN" query-param="EXPIRES_IN"/>
<with-param name="REFRESH_TOKEN" query-param="REFRESH_TOKEN"/>
</call-query>
</operation>
<resource method="GET" path="GetLastToken" returnRequestStatus="true">
<call-query href="GetLastToken"/>
</resource>
<resource method="POST" path="AddNewToken" returnRequestStatus="true">
<call-query href="AddNewToken">
<with-param name="ACCESS_TOKEN" query-param="ACCESS_TOKEN"/>
<with-param name="TOKEN_TYPE" query-param="TOKEN_TYPE"/>
<with-param name="API_SERVER" query-param="API_SERVER"/>
<with-param name="CREATED" query-param="CREATED"/>
<with-param name="EXPIRES_IN" query-param="EXPIRES_IN"/>
<with-param name="REFRESH_TOKEN" query-param="REFRESH_TOKEN"/>
</call-query>
</resource>
<resource method="POST" path="AddNewToken2" returnRequestStatus="true">
<call-query href="AddToken">
<with-param name="ACCESS_TOKEN" query-param="ACCESS_TOKEN"/>
<with-param name="TOKEN_TYPE" query-param="TOKEN_TYPE"/>
<with-param name="API_SERVER" query-param="API_SERVER"/>
<with-param name="CREATED" query-param="CREATED"/>
<with-param name="EXPIRES_IN" query-param="EXPIRES_IN"/>
<with-param name="EXPIRATION" query-param="EXPIRATION"/>
<with-param name="REFRESH_TOKEN" query-param="REFRESH_TOKEN"/>
</call-query>
</resource>
<query id="AddToken" useConfig="QT_DB">
<sql>INSERT INTO QT_DB.OAUTH_TOKEN (ACCESS_TOKEN, TOKEN_TYPE, API_SERVER, CREATED, EXPIRES_IN, EXPIRATION, REFRESH_TOKEN) VALUES(:ACCESS_TOKEN, :TOKEN_TYPE, :API_SERVER, :CREATED, :EXPIRES_IN, :EXPIRATION, :REFRESH_TOKEN);</sql>
<param name="ACCESS_TOKEN" sqlType="STRING" type="IN"/>
<param name="TOKEN_TYPE" sqlType="STRING" type="IN"/>
<param name="API_SERVER" sqlType="STRING" type="IN"/>
<param name="CREATED" sqlType="TIMESTAMP" type="IN"/>
<param name="EXPIRES_IN" sqlType="INTEGER" type="IN"/>
<param defaultValue="0" name="EXPIRATION" sqlType="TIMESTAMP" type="IN"/>
<param name="REFRESH_TOKEN" sqlType="STRING" type="IN"/>
</query>
</data>
这是我尝试做的帖子:
{
"AddNewToken2": {
"ACCESS_TOKEN": "2GQL1fo_bHv9GwIALgMhF5cuxynFrbHC0",
"TOKEN_TYPE": "Bearer",
"API_SERVER": "https://api04.iq.questrade.com/",
"CREATED": "2017-09-10T15:05:21.000-04:00",
"EXPIRES_IN": "1800",
"EXPIRATION": "2017-09-10T15:05:21.000-04:00",
"REFRESH_TOKEN": "bz8O65CN9HYA2ripBhV9M5q7He65Ebls0"
}
}
我得到的错误是:
[2017-09-10 22:59:07,433] [EI-Core] ERROR - ServerWorker Error processing POST reguest for : /services/OAuthToken.HTTPEndpoint/AddNewToken2. Error detail: null.
java.lang.NullPointerException
at org.apache.axis2.json.gson.GsonXMLStreamReader.validateArgumentTypes(GsonXMLStreamReader.java:783)
at org.apache.axis2.json.gson.GsonXMLStreamReader.nextValue(GsonXMLStreamReader.java:734)