Invoking webservice with Coldfusion keeps giving a "Connection Timing Out" Error

I have been working on this for hours and can't work it out.  You can find reference to the webserver documentation at http://help.cj.com/en/web_services/web_services.htm "click "Real time commission report" then "real time commission service".  The wsdl file is at https://rtpubcommission.api.cj.com/services/realtimeCommissionService?wsdl.  Here is the error detail, stack trace, and fault string
********************error
Cannot perform web service invocation retrieveLatestTransactions. The fault returned when invoking the web service operation is:<br> <pre>AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.net.ConnectException: Connection timed out: connect faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:548) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.&lt;init&gt;(SSLSocketImpl.java:351) at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71) at org.apache.axis.components.net.JSSESocketFactory.create(JSSESock... ''</pre> <br>The error occurred on line 57.

**********trace

coldfusion.xml.rpc.ServiceProxy$ServiceInvocationException: Cannot perform web service invocation retrieveLatestTransactions. at coldfusion.xml.rpc.ServiceProxy.invokeImpl(ServiceProxy.java:230) at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:143) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2211) at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:417) at cftestWS2ecfm1848655675.runPage(C:\Websites\149293nm7\_action\testWS.cfm:57) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at com.seefusion.Filter.doFilter(Filter.java:49) at com.seefusion.SeeFusion.doFilter(SeeFusion.java:1471) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)

*****************fault string

AxisFault faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException faultSubcode: faultString: java.net.ConnectException: Connection timed out: connect faultActor: faultNode: faultDetail: {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection timed out: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:519) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:548) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.&lt;init&gt;(SSLSocketImpl.java:351) at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(SSLSocketFactoryImpl.java:71) at org.apache.axis.components.net.JSSESocketFactory.create(JSSESocketFactory.java:92) at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:190) at org.apache.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:403) at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:137) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) at org.apache.axis.client.Call.invokeEngine(Call.java:2765) at org.apache.axis.client.Call.invoke(Call.java:2748) at org.apache.axis.client.Call.invoke(Call.java:2424) at org.apache.axis.client.Call.invoke(Call.java:2347) at org.apache.axis.client.Call.invoke(Call.java:1804) at com.cj.api.RealtimeCommissionServiceHttpBindingStub.retrieveLatestTransactions(RealtimeCommissionServiceHttpBindingStub.java:201) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at coldfusion.xml.rpc.ServiceProxy.invokeImpl(ServiceProxy.java:223) at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:143) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2211) at coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:417) at cftestWS2ecfm1848655675.runPage(C:\Websites\149293nm7\_action\testWS.cfm:57) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:192) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:366) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:279) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:86) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28) at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38) at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46) at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38) at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22) at coldfusion.CfmServlet.service(CfmServlet.java:175) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) at com.seefusion.Filter.doFilter(Filter.java:49) at com.seefusion.SeeFusion.doFilter(SeeFusion.java:1471) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42) at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46) at jrun.servlet.FilterChain.doFilter(FilterChain.java:94) at jrun.servlet.FilterChain.service(FilterChain.java:101) at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106) at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42) at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:284) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:203) at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320) at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428) at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266) at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66) {http://xml.apache.org/axis/}hostname:Turkey

<cfscript>
    // Define the values to pass to the object
	turl = "https://rtpubcommission.api.cj.com/services/realtimeCommissionService?wsdl";
	tmethod = "retrieveLatestTransactions";
    tdeveloperKey = "00894191cecab15e62eb37e3232cd38ba83576cc56d";
    twebsiteIds = "";
    tlookBackXHours = "3";
    tadvertiserIds = "";
    tcountries = "all";
    tadIds = "all";
    tincludeDetails = "";
    tsortBy = "";
    tsortOrder = "asc";
</cfscript>
 
<cfinvoke 
    webservice="#turl#"
    method="#tmethod#"
    returnvariable="aHashMap">
        <cfinvokeargument name="developerKey" value="#tdeveloperKey#" omit="yes"/>
        <cfinvokeargument name="websiteIds" value="#twebsiteIds#" omit="yes"/>
        <cfinvokeargument name="lookBackXHours" value="#tlookBackXHours#" omit="yes"/>
        <cfinvokeargument name="advertiserIds" value="#tadvertiserIds#" omit="yes"/>
        <cfinvokeargument name="countries" value="#tcountries#" omit="yes"/>
        <cfinvokeargument name="adIds" value="#tadIds#" omit="yes"/>
        <cfinvokeargument name="includeDetails" value="#tincludeDetails#" omit="yes"/>
        <cfinvokeargument name="sortBy" value="#tsortBy#" omit="yes"/>
        <cfinvokeargument name="sortOrder" value="#tsortOrder#" omit="yes"/>
</cfinvoke>
 
<cfdump var="#aHashMap#" />

Open in new window

duanehardyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mrcoffee365Connect With a Mentor Commented:
Okay, it looks as if you are supposed to give the ColdFusion webservice parameter the wsdl URL, so go back to that.  But I see that the examples in the article don't have "omit=yes" so don't use it.

wsdl2java is a tool that comes with the jakarta open source project Axis for Web Services:
http://ws.apache.org/axis/java/user-guide.html

You can google for it to see various sites, including the one above, which talk about how to use it.

Back to your own problem -- I find that getting a public Web service to work is often a very iterative process, which you're going through now.  The forums that most services offer can be very helpful.  When I searched the cj.com forums for cfinvoke, I found a few people using the services.  This thread, in particular, might be helpful for you:
http://webservices.cj.com/ws/forum/viewtopic.php?forum=5&showtopic=2052&highlight=cfinvoke

Also, I don't think you've declared your response variable correctly.  It should be a structure which matches the RealTimeCommission response declaration.  I don't see how the response will be automatically turned into a HashMap, if that is what you have #aHashMap# declared as.

See the RealTimeCommission documentation here:
http://help.cj.com/en/web_services/web_services.htm
and here:
http://help.cj.com/en/web_services/web_services.htm

Also, are you using the new version of the RealTimeCommission wsdl?  This URL works as well for the wsdl, and might work better for you:
https://rtpubcommission.api.cj.com/wsdl/version2/realtimeCommissionService.wsdl
0
 
mrcoffee365Commented:
Usually the connection times out because you're not making the connection correctly for the remote Web server.  It appears that rtpubcommission.api.cj.com is listening on 443, so it looks as if the Web server is there and listening.

Why do you have
omit="yes"
on every argument passed to the Web service?  The documentation says that at least the developerKey and lookBackXHours are required.

My guess, however, is that your url is wrong.  You don't usually send a request to the wsdl.  Have you tried:
https://rtpubcommission.api.cj.com/services/realtimeCommissionService

as your url?
0
 
duanehardyAuthor Commented:
I remove the omit statment and tried the url without ?wsdl.  I get the following error:

Cannot generate stub objects for web service invocation. Name: https://rtpubcommission.api.cj.com/services/realtimeCommissionService. WSDL: https://rtpubcommission.api.cj.com/services/realtimeCommissionService. WSDLException (at /html): faultCode=INVALID_WSDL: Expected element '{http://schemas.xmlsoap.org/wsdl/}definitions'.: It is recommended that you use a web browser to retrieve and examine the requested WSDL document to ensure it is correct. If the requested WSDL document cannot be retrieved or is dynamically generated, it is likely that the target web service has programming errors. <br>The error occurred on line 128.

I found an article that might be the essence of my problem at http://www.mischefamily.com/nathan/index.cfm/2007/2/8/ColdFusion-and-ASPNET-Web-Service-Interoperability-Part-III .  Several articles, including this one, reference an article with the answer http://hcc.musc.edu/research/shared_resources/xml_complex_types_to_cf_structure_notes.cfm but the page is no longer at this address.  

One recommendation from the article is to "run the WSDL through the WSDL2Java tool" to determine the methods expected to be passed.  I have been unable to find how to "run the WSDL through the WSDL2Java tool".  Can you or anyone help along these lines?  Or does the new error message I am receiving give you a heads up on the true answer?
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
mrcoffee365Commented:
Sorry -- just realized that the URLs for the API documentation and the Examples are not given in the above URLs:
API:
http://help.cj.com/en/web_services/Real_Time_Commission_Service.htm
Examples:
http://help.cj.com/en/web_services/Example_Queries_Real_Time_Commission.htm
0
 
duanehardyAuthor Commented:
I still couldn't get it to work with RealTimeCommission but I found where you had pulled the wsdl url and got it to work using ProductCatalogSearchService.  Thanks for the url idea, that worked!  

For the return, I was only dumping aHashMap which returns the following:
******************************************
object of com.cj.service.product.ProductResponse
 
Class Name com.cj.service.product.ProductResponse
Methods Method  Return Type  
equals(java.lang.Object) boolean
getCount() java.lang.Integer
getDeserializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName) org.apache.axis.encoding.Deserializer
getOffset() java.lang.Integer
getProducts() com.cj.domain.product.ArrayOfProduct
getSerializer(java.lang.String, java.lang.Class, javax.xml.namespace.QName) org.apache.axis.encoding.Serializer
getTotalResults() java.lang.Integer
getTypeDesc() org.apache.axis.description.TypeDesc
hashCode() int
setCount(java.lang.Integer) void
setOffset(java.lang.Integer) void
setProducts(com.cj.domain.product.ArrayOfProduct) void
setTotalResults(java.lang.Integer) void
*********************************************
 
The commission junction thread you posted shows the following example to return the data, but I get the error code "Element 0 is undefined in a Java object of type class com.cj.domain.product.ArrayOfProduct."  
***********************CJ Thread************************************
<Cfset tmpProducts = tmpOutput.getProducts()>

        <br/><b>#tmpOutput.getCount()# / #tmpOutput.getTotalPossible()# (#tmpOutput.getOffset()#)</b><br/><br/><<cfflush>

        <cfloop index="i" from="1" to="#tmpOutput.getCount()#">

                <b>#i#)</b> #tmpProducts[i].getName()# [sku: #tmpProducts[i].getSku()# -- upc: #tmpProducts[i].GetUpc()#] - #DollarFormat(tmpProducts[i].getPrice())# - #tmpProducts[i].getAdvertiserName()# (#tmpProducts[i].getAdvertiserId()#)<br/>
                <!--- <img src="#tmpProducts[i].getImageUrl()#"/><br/> --->
                #tmpProducts[i].getDescription()#<br/>
                #tmpProducts[i].getClickUrl()#<br/><br/>
                <Cfflush>
        </cfloop>
******************************************
I've attached my code.  How did I set it up as a structure that matches?
<cfinvoke webservice="https://rtpubcommission.api.cj.com/wsdl/version2/productSearchServiceV2.wsdl" method="search" returnvariable="products">
        <cfinvokeargument name="developerKey" value="00894191cecab15e62eb37e3232cd38ba83576cc56d5120944dae0fdffea8215276aff8032e287ce79720e74a456ead773c1c6c3d14f82fd893ac5391eafeec505/6ba7a5408814c44e5be5d2dec50b0bd01c571880c6d045badede77fae129b482b53177d17305170981caee48c2beafe688c2685fc35cd30f9cfbcb51bc35d605"/>
        <cfinvokeargument name="websiteId" value="2120973" />
  		<cfinvokeargument name="advertiserIds" value="joined" /> 
  		<cfinvokeargument name="keywords" value="" /> 
  		<cfinvokeargument name="serviceableArea" value="US" /> 
      	<cfinvokeargument name="upc" value="" /> 
        <cfinvokeargument name="manufacturerName" value="Nike" /> 
  		<cfinvokeargument name="manufacturerSku" value="" />
     	<cfinvokeargument name="advertiserSku" value="" /> 
       	<cfinvokeargument name="lowPrice" value="" />
        <cfinvokeargument name="highPrice" value="" />
        <cfinvokeargument name="lowSalePrice" value="" /> 
        <cfinvokeargument name="highSalePrice" value="" /> 
        <cfinvokeargument name="currency" value="" />
     	<cfinvokeargument name="isbn" value="" /> 
        <cfinvokeargument name="sortBy" value="" /> 
  		<cfinvokeargument name="sortOrder" value="" /> 
        <cfinvokeargument name="startAt" value="0"/>
        <cfinvokeargument name="maxResults" value="25"/>
</Cfinvoke>
 
<cfset product = products.getProducts()>
 
<cfloop index="i" from="1" to="#arraylen(products)#">
<cfoutput>#product[i].getImageURL()#</cfoutput>
</cfloop>

Open in new window

0
 
duanehardyAuthor Commented:
I meant to ask "How DO I set it up as a structure that matches?" not " How did I set it up as a structure that matches?"
0
 
mrcoffee365Commented:
Good work finding an example that works better for you.

I found this documentation by googling for cfinvoke and webservice:
http://www.webreference.com/programming/coldfusion/1/5.html

Basically, you can loop over the elements, similarly to how you have it above.  However, I think the dot notation might work better as in this example (from the above page).  Also, I think you should loop over aHashMap rather than the secondary object -- but your way might be fine, once we get a sample working.

Example from link above:
<cfinvoke
  webservice="http://www.xmethods.net/wsdl/query.wsdl"
  method="getServiceSummariesByPublisher"
  returnvariable="aServiceSummaryArray">
    <cfinvokeargument name="publisherID" value="xmethods.net"/>
</cfinvoke>
   
<table border="1">
  <tr>
    <th>Is Structure?</th>
    <th>id</th>
    <th>name</th>
    <th>publisherID</th>
    <th>shortDescription</th>
    <th>wsdlURL</th>
  </tr>
<cfloop index="i" from="1" to="10">
  <cfoutput>
  <tr>
    <td>#isStruct(aServiceSummaryArray[i])#</td>
    <td>#aServiceSummaryArray[i].id#</td>
    <td>#aServiceSummaryArray[i].name#</td>
    <td>#aServiceSummaryArray[i].publisherID#</td>
    <td>#aServiceSummaryArray[i].shortDescription#</td>
    <td>#aServiceSummaryArray[i].wsdlURL#</td>
  </tr>
  </cfoutput>    
</cfloop>
</table>

Although you want to keep the part you have in your code where you loop to the length of the Web service output array.  You don't want to try to loop past the length of the array.
0
 
duanehardyAuthor Commented:
mrcoffee365,

thank you again for your help.  I too had found this example, along with some others in my quest to output the results.  I had tried it before and it didn't work.  I ended up doing a cfdump for the var product.  It exposed another method of getProduct(). I set item = product.getProduct() and then I could loop through the array with . notation.  isStruct was not needed.  In a nutshell:

<cfinvoke ....returnvariable="products">
<cfset product = products.getProducts() />
<cfset item = product.getProduct() />
<TABLE>
<cfloop from="1" to="#arraylen(product)#" index="i">
<cfoutput>
<tr>
<td>#product[i].price#</td>
<td>#product[i].adId#</td>
</tr>
</cfoutput>
</cfloop>
</table>

Thanks again for all the help.  You got me on the right track.  I've pull rss and xml feeds via cfhttp many times before but this is the very first time that I called a webservice.  I learned not to fully trust old code examples.  As the wsdl definitions change over time and the xml structure is changed so does the code required.  Time consuming lesson but a valuable one!  Thanks again.
0
 
duanehardyAuthor Commented:
Just caught a typo in my last post.  Should be item[i] not product[i]. Loop should read.

<cfloop from="1" to="#arraylen(product)#" index="i">
<cfoutput>
<tr>
<td>#item[i].price#</td>
<td>#item[i].adId#</td>
</tr>
</cfoutput>
</cfloop>
0
 
mrcoffee365Commented:
Glad to help.

Thanks for posting your final code sample.  This stuff is tricky, and the more good examples we have on EE, the better for everyone.

I like the support in ColdFusion for dealing with Web services.  They've done a good job of balancing the need for flexibility with the desire to just get something working.

0
All Courses

From novice to tech pro — start learning today.