【问题标题】:Issue in Get argument property inside the Payload Factory有效负载工厂内的获取参数属性中的问题
【发布时间】:2013-06-20 05:00:51
【问题描述】:

我正在尝试通过 ESB 从 JSON 客户端向 DSS 服务器调用请求,我正在尝试调用获取数据服务,客户端代码、ESB Insequence 配置如下所示。我收到如下所示的服务器错误:

LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:da913ea8-4122-4f58-9732-4106a55b465a, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = 发回消息时出现意外错误,信封:

客户端代码是:

 URL url = new URL("http://xxx:xx:xx:xxx/entitytype");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", "application/json");
    String studentDetails = "{\"hierarchyEntityRequest\":{\"entityName\":\"Chandragiri\",\"parentEntity\":900000001}}";

    System.setProperty("studentDetails",studentDetails);
    OutputStream os = conn.getOutputStream();
    os.write(studentDetails.getBytes());
    os.flush();

    if (conn.getResponseCode() != HttpURLConnection.HTTP_CREATED) {
        throw new RuntimeException("Failed : HTTP error code : "
                + conn.getResponseCode());
    }

    BufferedReader br = new BufferedReader(new InputStreamReader(
            (conn.getInputStream())));


    conn.disconnect();

} catch (MalformedURLException e) {

    e.printStackTrace();

} catch (IOException e) {

    e.printStackTrace();

}

ESB 配置服务是:

           <payloadFactory>
  <format>
     <p:getEntityById xmlns:p="http://com.pcs.entity">
           <xs:data xmlns:xs="http://com.pcs.entity">get-property('uri.var.myhierachy')</xs:data>
        </p:getEntityById>
     </format>
     <args>
        <arg xmlns:ns="http://org.apache.synapse/xsd" expression="get-property('uri.var.myhierachy')"/>
     </args>
  </payloadFactory>
  <enrich>
     <source clone="true" type="body"/>
     <target action="replace" type="property" property="myhierachy"/>
  </enrich>
<enrich>
     <source clone="true" type="body"/>
     <target action="replace" type="property" property="myhierachy"/>
  </enrich>
  <send>
     <endpoint key="HierarchyService"/>
  </send>
  <property name="messageType" value="application/json" scope="axis2" type="STRING"/>
  <log level="full" category="TRACE"/>

【问题讨论】:

    标签: java rest wso2 wso2esb


    【解决方案1】:

    如果您想将消息发送到 DSS 服务器并且不回复,您可以将“OUT_ONLY”属性指定为“true”,如下所述。

    <property action="set" name="OUT_ONLY" value="true"/>
    

    如果您想将响应返回给您的客户,您可以将调解器作为配置的最后一个元素或在输出序列中。

    <send/>
    

    【讨论】:

      猜你喜欢
      • 2013-05-17
      • 1970-01-01
      • 1970-01-01
      • 2019-11-09
      • 1970-01-01
      • 1970-01-01
      • 2021-07-02
      • 2021-01-21
      • 1970-01-01
      相关资源
      最近更新 更多