2016-07-15 19 views
0

Ich versuche, 2 verschiedene API zu klonen, um ihre Antwort zu kombinieren, aber ich bekomme immer einen Nullzeigerfehler. zuerst versuche ich nur diese 2 api zu klonen.wso2 Klonen von zwei verschiedenen api

<?xml version="1.0" encoding="UTF-8"?> 
<api context="/movieapi" name="movieapi" xmlns="http://ws.apache.org/ns/synapse"> 
    <resource methods="GET" uri-template="/movie/{imdbId}"> 
     <inSequence> 
      <property expression="get-property('uri.var.imdbId')" name="uri.var.imdbId" scope="default" type="STRING"/> 
      <clone> 
       <target> 
        <endpoint> 
         <address trace="disable" uri="https://api.themoviedb.org/3/movie/{uri.var.imdbId}?api_key=code&amp;append_to_response=casts,images"/> 
        </endpoint> 
       </target> 
       <target> 
        <endpoint> 
         <address trace="disable" uri="http://www.omdbapi.com/?type=movie&amp;i={uri.var.imdbId}"/> 
        </endpoint> 
       </target> 
      </clone> 
     </inSequence> 
    </resource> 
</api> 

Hier ist mein Fehler von wso2esb Version 5 Beta

[2016-07-15 13:57:34,106] ERROR - PassThroughHttpSender Failed to submit the response 
java.lang.NullPointerException 
    at org.apache.synapse.transport.passthru.util.SourceResponseFactory.create(SourceResponseFactory.java:67) 
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:463) 
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:264) 
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442) 
    at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212) 
    at org.apache.synapse.rest.Resource.process(Resource.java:348) 
    at org.apache.synapse.rest.API.process(API.java:336) 
    at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:120) 
    at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:100) 
    at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:55) 
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304) 
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:541) 
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:179) 
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) 
    at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:252) 
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
[2016-07-15 13:57:34,121] ERROR - Axis2Sender Access-Control-Allow-Origin:*,Cache-Control:public, max-age=28800,Content-Type:application/json;charset=utf-8,ETag:"37a6259cc0c1dae299a7866489dff0bd",Status:404 Not Found,X-Memc:MISS,X-Memc-Age:0,X-Memc-Expires:28800,X-Memc-Key:d0c5ca8e07e81f5246e96c9e4bd54753,X-RateLimit-Limit:40,X-RateLimit-Remaining:39,X-RateLimit-Reset:1468562263,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope> Unexpected error sending message back 
org.apache.axis2.AxisFault: Failed to submit the response 
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.handleException(PassThroughHttpSender.java:613) 
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:266) 
    at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442) 
    at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212) 
    at org.apache.synapse.rest.Resource.process(Resource.java:348) 
    at org.apache.synapse.rest.API.process(API.java:336) 
    at org.apache.synapse.rest.RESTRequestHandler.apiProcess(RESTRequestHandler.java:120) 
    at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:100) 
    at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:55) 
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:304) 
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:541) 
    at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:179) 
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180) 
    at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:252) 
    at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: java.lang.NullPointerException 
    at org.apache.synapse.transport.passthru.util.SourceResponseFactory.create(SourceResponseFactory.java:67) 
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:463) 
    at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:264) 
    ... 16 more 
[2016-07-15 13:57:34,124] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:f814f333-463b-4f51-89f1-2c361d7c55ae, Direction: response, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Access-Control-Allow-Origin:*,Cache-Control:public, max-age=28800,Content-Type:application/json;charset=utf-8,ETag:"37a6259cc0c1dae299a7866489dff0bd",Status:404 Not Found,X-Memc:MISS,X-Memc-Age:0,X-Memc-Expires:28800,X-Memc-Key:d0c5ca8e07e81f5246e96c9e4bd54753,X-RateLimit-Limit:40,X-RateLimit-Remaining:39,X-RateLimit-Reset:1468562263,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope> Unexpected error sending message back, Payload: {"status_code":34,"status_message":"The resource you requested could not be found."} 

Antwort

0

Bitte überprüfen Sie, ob Ihr Eigenschaftswert aus der Eigenschaft abzurufen. Verwenden Sie dazu den Protokollmediator wie folgt;

<log level="full"> 
<property expression="get-property('uri.var.imdbId')" name="uri.var.imdbId" scope="default" type="STRING"/> 
</log> 

Dann ist das Problem Teil abrufen.

Problem ist das Einreichen der Antwort. Gemäß Ihrer Konfiguration haben Sie keinen Aggregatmediator hinzugefügt, um Antworten zu sammeln [1]. Bitte fügen Sie hinzu und testen Sie es.

Ich füge Beispiel Szenario hier. Sie müssen nur 2 Instanzen des SimpleStockQuote-Dienstes [2] starten und Nachrichten über SOAPUI auf dem Proxy veröffentlichen.

<proxy name="ScatterGatherProxy" startOnLoad="true" trace="disable" transports="https http"> 
<description/> 
<target> 
    <inSequence> 
     <clone> 
      <target> 
       <sequence> 
        <send> 
         <endpoint name="vendorA"> 
          <address uri="http://localhost:9001/services/SimpleStockQuoteService/"/> 
         </endpoint> 
        </send> 
       </sequence> 
      </target> 
      <target> 
       <sequence> 
        <send> 
         <endpoint name="vendorB"> 
          <address uri="http://localhost:9002/services/SimpleStockQuoteService/"/> 
         </endpoint> 
        </send> 
       </sequence> 
      </target> 
     </clone> 
    </inSequence> 
    <outSequence> 
     <log level="full"/> 
     <aggregate> 
      <completeCondition> 
       <messageCount min="2"/> 
      </completeCondition> 
      <onComplete expression="//m0:return" 
       xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd"> 
       <enrich> 
        <source clone="true" xpath="//m0:return[not(preceding-sibling::m0:return/m1:last &lt;= m1:last) and not(following-sibling::m0:return/m1:last &lt; m1:last)]"/> 
        <target type="body"/> 
       </enrich> 
       <send/> 
      </onComplete> 
     </aggregate> 
    </outSequence> 
</target> 

[1] https://docs.wso2.com/display/ESB490/Aggregate+Mediator

[2] https://docs.wso2.com/display/ESB490/Setting+Up+the+ESB+Samples#Starting%20the%20Axis2%20server

+0

sie den Wert aus der Eigenschaft nicht abgerufen werden. '[2016-07-15 14: 17: 40,029] INFO - LogMediator An:/movieapi/movie/tt0918940, MessageID: urn: uuid: be033ca6-0430-4284-9942-569d65fe8f87, Richtung: Anfrage, uri.var. imdbId = tt0918940, Umschlag: ' –

+1

Fehler ist über die Antwort fehlgeschlagen. Sie haben keinen Vermittler gestellt, um die Antwort zu erhalten. Sie sollten Aggregat Mediator hinzufügen, um Antworten von Endpunkten zu erhalten –

+0

Meine Antwort mit Referenzen geändert. –