[英]Why I am getting the WSO2 DSS Mapping issue?
I am trying to map my MongoDB with the WSO2 DSS
. 我正在尝试使用WSO2 DSS
映射我的MongoDB。 But the service generated is faulty and getting many errors regarding the mapping of the data. 但是生成的服务有问题,并且在数据映射方面会出现许多错误。
Here is what I tried: 这是我尝试过的:
<data name="MongoDB" transports="http https local">
<config enableOData="false" id="mongodb">
<property name="mongoDB_servers">127.0.0.1:27017</property>
<property name="mongoDB_database">domain_with_email</property>
<property name="mongoDB_write_concern">NONE</property>
<property name="mongoDB_read_preference">PRIMARY</property>
</config>
<query id="search" useConfig="mongodb">
<expression>domainemail.find({"domain":#})</expression>
<result escapeNonPrintableChar="true" outputType="json" useColumnNumbers="true">{
"entries":
{
"id":"$_id",
"domain":"$domain",
"emails":[
 {
 "email":"$email"
 }
]
}
}</result>
<param defaultValue="yahoo.com" name="domain" sqlType="STRING"/>
</query>
<operation name="search">
<call-query href="search">
<with-param name="domain" query-param="domain"/>
</call-query>
</operation>
</data>
Here is the errors: 错误如下:
https://gist.github.com/JafferWilson/b4aa22c39205d61a25f2bee5b45a7607 https://gist.github.com/JafferWilson/b4aa22c39205d61a25f2bee5b45a7607
Kindly let me know what I need to do to get a JSON output from my MongoDB using WSO2 DSS? 请让我知道我该怎么做才能使用WSO2 DSS从MongoDB中获取JSON输出?
We're still struggling with our WSO2 + Mongo journey too. 我们也仍在为我们的WSO2 + Mongo旅程挣扎。 Anyhow I hope this can help. 无论如何,我希望这会有所帮助。 Here's our code for a working JSON service to MongoDB 这是用于MongoDB的有效JSON服务的代码
<data name="MongoTestDS2" transports="http https local">
<config enableOData="false" id="MongoDS">
<property name="mongoDB_servers">xx.xx.xx.xx</property>
<property name="mongoDB_database">mydb</property>
</config>
<query id="GetTestVals" useConfig="MongoDS">
<expression>things.find()</expression>
<result element="Documents" rowName="Document" useColumnNumbers="true">
<element column="document" export="id" name="Data" xsdType="string"/>
</result>
</query>
<query id="InsertTestVals" returnUpdatedRowCount="true" useConfig="MongoDS">
<expression>things.insert("{id:#, name:#}")</expression>
<result element="UpdatedRowCount" rowName="" useColumnNumbers="true">
<element column="1" name="Value" xsdType="integer"/>
</result>
<param name="id" sqlType="STRING"/>
<param name="name" sqlType="STRING"/>
</query>
<query id="GetValsJson" useConfig="MongoDS">
<expression>things.find()</expression>
<result outputType="json">{
 "Documents": {
 "Document": [
 {
 "Data": "$document"
 }
 ]
 }
}</result>
</query>
<operation name="GetThings">
<description>Test Mongo DB 
 </description>
<call-query href="GetTestVals"/>
</operation>
<operation name="PutThings">
<call-query href="InsertTestVals">
<with-param name="id" query-param="id"/>
<with-param name="name" query-param="name"/>
</call-query>
</operation>
<operation name="GetThingsJson">
<call-query href="GetValsJson"/>
</operation>
</data>
In your case I think, it's this line you need to change: 我认为您需要更改的是这行:
<query id="GetValsJson" useConfig="MongoDS">
<expression>things.find()</expression>
<result outputType="json">{
 "Documents": {
 "Document": [
 {
 "Data": "$document"
 }
 ]
 }
}</result>
</query>
This returns all the fields into a string. 这会将所有字段返回到字符串中。
If this is then related to your earlier question, then I think this tutorial will help with the next step of mapping field from one service to another: https://docs.wso2.com/display/EI611/Transforming+Message+Content 如果这与您先前的问题有关,那么我认为本教程将有助于下一步将字段从一种服务映射到另一种服务: https : //docs.wso2.com/display/EI611/Transforming+Message+Content
On our side, we unfortunately gave up on the mongodb adapter that comes with WSO2 and used RESTHeart to expose the mongodb as APIs ( http://restheart.org/ ) This seems to work well as WSO2 then just consumes them as if they were any other REST API. 在我们这边,不幸的是,我们放弃了WSO2随附的mongodb适配器,并使用RESTHeart将mongodb作为API公开( http://restheart.org/ ),因为WSO2然后就像消耗了它们一样消耗掉了它们,这似乎运行良好任何其他REST API。
We'd love to hear how you get on as I'm sure we'll hit many of the same challenges in our own mongodb + WSO2 testing. 我们很想听听您的情况,因为我确信我们在自己的mongodb + WSO2测试中会遇到许多相同的挑战。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.