小编Ani*_*ary的帖子

如何在OpenAPI(Swagger)中描述此POST JSON请求主体?

我有一个POST请求,它使用以下JSON请求体.如何使用OpenAPI(Swagger)描述此请求体?

{
    "testapi": {
        "testapiContext": {
            "messageId": "kkkk8",
            "messageDateTime": "2014-08-17T14:07:30+0530"
        },
        "testapiBody": {
            "cameraServiceRq": {
                "osType": "android",
                "deviceType": "samsung555"
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

到目前为止,我尝试了以下内容,但我仍然坚持定义身体schema.

swagger: "2.0"
info:
  version: 1.0.0
  title: get camera
  license:
    name: MIT
host: localhost
basePath: /test/service
schemes:
  - http
consumes:
  - application/json
produces:
  - application/json
paths:
  /getCameraParameters:
    post:
      summary: Create new parameters
      operationId: createnew
      consumes:
        - application/json
        - application/xml
      produces:
        - application/json
        - application/xml
      parameters:
        - name: pet
          in: body
          description: The pet JSON you …
Run Code Online (Sandbox Code Playgroud)

swagger swagger-2.0 openapi

42
推荐指数
3
解决办法
8万
查看次数

如何修复soapenv:在使用SOAP请求/响应进行验证时,XSD架构中的信封问题

我有一个SOAP请求: -

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://services.test.com/schema/MainData/V1">
   <soapenv:Header/>
   <soapenv:Body>
      <v1:retrieveDataRequest>
         <v1:Id>58</v1:Id>
      </v1:retrieveDataRequest>
   </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

和SOAP响应: -

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <retrieveDataResponse xmlns="http://services.test.com/schema/MainData/V1">
         <Response>The Data retrieved from the Database</Response>
         <Id>58</Id>
         <Name>fdfdf</Name>
         <Age>44</Age>
         <Designation>sse</Designation>
      </retrieveDataResponse>
   </soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)

现在我的XSD架构是: -

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" 
targetNamespace="http://services.test.com/schema/MainData/V1" 
xmlns:tns="http://services.test.com/schema/MainData/V1" elementFormDefault="qualified">

    <complexType name="dataRequest">
        <sequence>
            <element name="Id" type="int"></element>
            <element name="Name" type="string"></element>
            <element name="Age" type="int"></element>
            <element name="Designation" type="string"></element>
        </sequence>
    </complexType>

    <complexType name="dataResponse">
        <sequence>
            <element name="Response" type="string"></element>
            <element name="Id" type="int"></element>
            <element name="Name" type="string"></element>
            <element name="Age" type="int"></element>
            <element name="Designation" type="string"></element>
        </sequence>
    </complexType>

    <element …
Run Code Online (Sandbox Code Playgroud)

xml validation xsd soap

9
推荐指数
1
解决办法
3万
查看次数

如何使用新的数据库端点从Mule 3.5调用存储过程

我正在使用存储过程测试Mule的Mule 3.5的新数据库连接器...(参考: - http://www.mulesoft.org/documentation/display/current/Database+Connector)..我有一个以下存储过程: -

ALTER PROCEDURE [dbo].[sp_retrieveData]
 @Id  int
AS
Select * from getData Where ID = @Id
Run Code Online (Sandbox Code Playgroud)

这是在骡子的旧JDBC连接器工作正常...我以前使用下面的语法来调用从JDBC端点的存储过程: - <jdbc-ee:query key="RetriveQuery" value="CALL sp_retrieveData(${Id})"/>这工作得很好......但是,现在的问题是骡子3.5新数据库的终点,我无法调用相同的存储过程...我的Mule配置是: -

<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
   <db:parameterized-query><![CDATA[CALL sp_retrieveData(58)]]></db:parameterized-query>
   <db:in-param name="Id" type="INTEGER" value="58"/>
  </db:stored-procedure>
Run Code Online (Sandbox Code Playgroud)

所以,我的问题是如何用新的DB端点调用存储过程...有没有人尝试过它...... ...请帮忙......

更新: - 我得到以下例外: -

Exception stack is:
1. The index 1 is out of range. (com.microsoft.sqlserver.jdbc.SQLServerException)
  com.microsoft.sqlserver.jdbc.SQLServerException:170 (null)
2. The index 1 is out of range. (com.microsoft.sqlserver.jdbc.SQLServerException). Message payload is of type: String (org.mule.api.MessagingException)
  org.mule.module.db.internal.processor.AbstractDbMessageProcessor:81 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack …
Run Code Online (Sandbox Code Playgroud)

stored-procedures jdbc mule mule-studio

5
推荐指数
1
解决办法
8651
查看次数

如何在Mule中验证内容类型= JSON

我有一个Mule配置,其中有2个流: - 一个流程公开REST服务: -

<flow name="restServiceFlow1" doc:name="restFlow1">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" doc:name="HTTP"/>
        <jersey:resources doc:name="REST">
            <component class="com.test.services.schema.maindata.v1.Impl.MainDataImpl"/>
        </jersey:resources>
 </flow>
Run Code Online (Sandbox Code Playgroud)

和另一个通过文件入站放置JSON请求来使用服务的流程: -

<flow name="restFlow2">
  <file:inbound-endpoint path="E:\backup\test" responseTimeout="10000" connector-ref="File_Global">
    <file:filename-regex-filter pattern="aa.txt" caseSensitive="false"/>
  </file:inbound-endpoint>

  <json:json-to-object-transformer returnClass="java.util.HashMap"/>

  <foreach collection="#[payload.insertDataRequest]">
    <http:outbound-endpoint exchange-pattern="request-response"
          contentType="application/json" method="GET"
          address="http://localhost:8082/getData/insert/?id=#[payload.id]&amp;name=#[payload.name]&amp;age=#[payload.age]&amp;designation=#[payload.designation]"/>
  </foreach>
</flow>
Run Code Online (Sandbox Code Playgroud)

现在要求在文件入站端点之后检查内容类型是否内容类型是JSON ...如果内容Type不等于JSON那么它将在日志中显示不是JSON消息.

我尝试了以下内容: - 我在文件入站端点后放置了一个选择路由器: -

<when evaluator="groovy" expression="payload.ContentType=='JSON'"> 
Run Code Online (Sandbox Code Playgroud)

检查内容类型有效负载,如果内容类型不是JSON,它将在日志中显示不是JSON,因此我将日志放在Default of choice路由器中...但是我得到以下异常: -

Exception stack is:
1. No such property: ContentType for class: org.mule.transport.file.ReceiverFileInputStream (groovy.lang.MissingPropertyException)
  org.codehaus.groovy.runtime.ScriptBytecodeAdapter:50 (null)
2. groovy.lang.MissingPropertyException: No such property: ContentType for class: org.mule.transport.file.ReceiverFileInputStream (javax.script.ScriptException)
  org.codehaus.groovy.jsr223.GroovyScriptEngineImpl:323 (http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/script/ScriptException.html) …
Run Code Online (Sandbox Code Playgroud)

validation json mule mule-el

2
推荐指数
1
解决办法
2173
查看次数

从mule流中的json响应中提取值

我有这样的json响应 - 我想提取p_ProviderID的值.请指导我如何在骡子流中做到这一点?

{ 
"category" : "Address",
"status": "SUCCESS",
"result":  {
              "p_ProviderID": 4, 
	      "p_NewProvInd": "Exist"
           }
} 
Run Code Online (Sandbox Code Playgroud)

json mule

1
推荐指数
1
解决办法
6546
查看次数