tExtractJsonFields error when restclient result array size is 0

Five Stars

tExtractJsonFields error when restclient result array size is 0

hi all:

 here is my design to get restult from rest api:

the patern of the restclient url is :

http://services.groupkt.com/state/search/{countryCode}?text={text to search}

the url is set is :

"http://services.groupkt.com/state/search/"+req.countryCode+"?text="+req.searchText

 

 1.png

 

2.png

 

when i call with parameter

 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.talend.org/service/">
   <soapenv:Header/>
   <soapenv:Body>
      <ser:CountrySearchWebServiceOperationRequest>
         <countryCode>IND</countryCode>
         <searchText>pradesh</searchText>
      </ser:CountrySearchWebServiceOperationRequest>
   </soapenv:Body>
</soapenv:Envelope>

the rest client URL should be:

 

http://services.groupkt.com/state/search/IND?text=pradesh

the json result should be:

 

{
  "RestResponse" : {
    "messages" : [ "Total [5] records found." ],
    "result" : [ {
      "id" : 69,
      "country" : "IND",
      "name" : "Madhya Pradesh",
      "abbr" : "MP",
      "area" : "72626809SKM",
      "largest_city" : "Bhopal",
      "capital" : "Bhopal"
    }, {
      "id" : 82,
      "country" : "IND",
      "name" : "Uttar Pradesh",
      "abbr" : "UP",
      "area" : "199812341SKM",
      "largest_city" : "Lucknow",
      "capital" : "Lucknow"
    }]
  }
}

the result is OK :

 

 

3.png

 

 

but when the paramter is changed, and the json "result" value is blank, the service throw an exception:

the parameter:

4.png

the rest client URL should be:

http://services.groupkt.com/state/search/IND?text=pradesh3

 

the result of the api is:

 

{
  "RestResponse" : {
    "messages" : [ "No matching state found for requested code [IND->pradesh3]." ],
    "result" : [ ]
  }
}

the talend studio print the error:

 

[WARN ]: org.apache.cxf.phase.PhaseInterceptorChain - Interceptor for {http://www.talend.org/service/}CountrySearchWebService#{http://www.talend.org/service/}CountrySearchWebServiceOperation has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Could not generate the XML stream caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [2,0].
	at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:115)
	at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:65)
	at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:53)
	at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:137)
	at org.apache.cxf.wsdl.interceptors.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
	at org.apache.cxf.interceptor.OutgoingChainInterceptor.handleMessage(OutgoingChainInterceptor.java:90)
	at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
	at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
	at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
	at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:247)
	at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:79)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1182)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1116)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:213)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:134)
	at org.eclipse.jetty.server.Server.handle(Server.java:534)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:320)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:273)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95)
	at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:93)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:303)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148)
	at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:136)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589)
	at java.lang.Thread.run(Unknown Source)
Caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
 at [row,col {unknown-source}]: [2,0]
	at com.ctc.wstx.sr.StreamScanner.throwUnexpectedEOF(StreamScanner.java:685)
	at com.ctc.wstx.sr.BasicStreamReader.handleEOF(BasicStreamReader.java:2141)
	at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
	at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1131)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:793)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:722)
	at org.apache.cxf.staxutils.StaxUtils.copy(StaxUtils.java:648)
	at org.apache.cxf.databinding.source.XMLStreamDataWriter.write(XMLStreamDataWriter.java:111)
	... 28 more

 

is that the empty "result" cause the error?

 

please help me out, thank you!

Five Stars

Re: tExtractJsonFields error when restclient result array size is 0

anyone had this problem?

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.