function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
cheekychopscheekychops 

Dynamic CXF client

i am trying to invoke the Web Service API using CXF's DynamicClientFactory, without success.

My stack trace is as follows:

14-Nov-2008 16:12:35 org.apache.cxf.endpoint.dynamic.DynamicClientFactory outputDebug
INFO: Created classes: com.sforce.soap.enterprise.AssignmentRuleHeader, com.sforce.soap.enterprise.ChildRelationship, com.sforce.soap.enterprise.ConvertLead, com.sforce.soap.enterprise.ConvertLeadResponse ...<snip>
Testsuite: com.cmc.crmbridge.services.salesforce.TestDynamicSalesForceWebServiceClient
14-Nov-2008 16:12:40 com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient logon
INFO: main Logging on to webservice as user smithcolina@hotmail.com
14-Nov-2008 16:12:41 org.apache.cxf.transport.https.SSLUtils getCiphersuites
INFO: The cipher suites have not been configured, falling back to cipher suite filters.
14-Nov-2008 16:12:41 org.apache.cxf.transport.https.SSLUtils getCiphersuites
INFO: The cipher suite filters have not been configured, falling back to default filters.
14-Nov-2008 16:12:41 org.apache.cxf.transport.https.SSLUtils getCiphersFromList
INFO: The cipher suites have been set to SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_KRB5_WITH_RC4_128_SHA, TLS_KRB5_WITH_RC4_128_MD5, TLS_KRB5_WITH_3DES_EDE_CBC_SHA, TLS_KRB5_WITH_3DES_EDE_CBC_MD5, TLS_KRB5_WITH_DES_CBC_SHA, TLS_KRB5_WITH_DES_CBC_MD5, TLS_KRB5_EXPORT_WITH_RC4_40_SHA, TLS_KRB5_EXPORT_WITH_RC4_40_MD5, TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA, TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5. 
14-Nov-2008 16:12:41 org.apache.cxf.transport.http.HTTPConduit prepare
INFO: AutoRedirect is turned on.
14-Nov-2008 16:12:41 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
org.apache.cxf.binding.soap.SoapFault: Error writing to XMLStreamWriter.
        at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:136)
        at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:76)
        at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:57)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:200)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:220)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:206)
        at com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient.invoke(DynamicSalesForceWebServiceClient.java:511)
        at com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient.logon(DynamicSalesForceWebServiceClient.java:217)
        at com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient.ping(DynamicSalesForceWebServiceClient.java:315)
        at com.cmc.crmbridge.services.salesforce.TestDynamicSalesForceWebServiceClient.testPing(TestDynamicSalesForceWebServiceClient.java:41)
        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 junit.framework.TestCase.runTest(TestCase.java:168)
        at junit.framework.TestCase.runBare(TestCase.java:134)
        at junit.framework.TestResult$1.protect(TestResult.java:110)
        at junit.framework.TestResult.runProtected(TestResult.java:128)
        at junit.framework.TestResult.run(TestResult.java:113)
        at junit.framework.TestCase.run(TestCase.java:124)
        at junit.framework.TestSuite.runTest(TestSuite.java:232)
        at junit.framework.TestSuite.run(TestSuite.java:227)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:515)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:1031)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:888)
Caused by: javax.xml.stream.XMLStreamException: java.net.SocketException: Unconnected sockets not implemented
        at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeStartElement(XMLStreamWriterImpl.java:1335)
        at org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:95)
        ... 27 more
Caused by: java.net.SocketException: Unconnected sockets not implemented
        at javax.net.SocketFactory.createSocket(SocketFactory.java:97)
        at sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:360)
        at sun.net.NetworkClient.doConnect(NetworkClient.java:145)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
        at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
        at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:271)
        at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:328)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
        at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:731)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
        at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:834)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleHeadersTrustCaching(HTTPConduit.java:1830)
        at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.onFirstWrite(HTTPConduit.java:1792)
        at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:59)
        at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:83)
        at org.apache.cxf.io.CacheAndWriteOutputStream.write(CacheAndWriteOutputStream.java:58)
        at com.sun.xml.internal.stream.writers.UTF8OutputStreamWriter.write(UTF8OutputStreamWriter.java:94)
        at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.openStartTag(XMLStreamWriterImpl.java:1559)
        at com.sun.xml.internal.stream.writers.XMLStreamWriterImpl.writeStartElement(XMLStreamWriterImpl.java:1294)
        ... 28 more

I have tried configuring CXF's httpConduit thus, but it did not help:

Code:
  <http:conduit name="*.http-conduit">
      <http:tlsClientParameters secureSocketProtocol="SSL">
   </http:tlsClientParameters>
   <http:authorization>
      <sec:UserName>smithcolina@hotmail.com</sec:UserName>
      <sec:Password>punchup1</sec:Password>
   </http:authorization>
      <http:client AutoRedirect="true" Connection="Keep-Alive" AllowChunking="false" />
   </http:conduit>

Any suggestions?

cheekychopscheekychops
Ooh some progress... I upgraded to CXF 2.1.3 and now I am getting...

Failed to invoke login
com.cmc.crmbridge.services.CRMServiceException: Failed to invoke login
        at com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient.invoke(DynamicSalesForceWebServiceClient.java:515)
        at com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient.logon(DynamicSalesForceWebServiceClient.java:217)
        at com.cmc.crmbridge.services.salesforce.DynamicSalesForceWebServiceClient.ping(DynamicSalesForceWebServiceClient.java:315)
        at com.cmc.crmbridge.services.salesforce.TestDynamicSalesForceWebServiceClient.testPing(TestDynamicSalesForceWebServiceClient.java:41)
Caused by: org.apache.cxf.binding.soap.SoapFault: INVALID_LOGIN: Invalid username, password, security token; or user locked out.



cheekychopscheekychops
Hmmm I'm still having trouble, despite resetting my security token and appending it to my password. Could it be I am locked out?
SuperfellSuperfell
Could be, I'd start by making sure you can login with a known working api client.
cheekychopscheekychops
You were right Simon, I tried the Axis Sample and it worked.

The problem is that I'd rather not switch from CXF unless I really have to.

I managed to get past the login method, but now I'm stuck with the exception below. I can see from the Sample that I'm supposed to set a property "SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY" to the value returned by the login call, but how do I do that with CXF? I've tried setting the property in the Map returned by
org.apache.cxf.endpoint.Client.getRequestContext(), but it doesn't work :smileysad:


Testcase: testPing(com.cmc.crmbridge.services.salesforce.TestSalesForceWebServiceClient):        Caused an ERROR
UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService
javax.xml.ws.soap.SOAPFaultException: UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145)
        at $Proxy42.describeGlobal(Unknown Source)
        at com.cmc.crmbridge.services.salesforce.SalesForceWebServiceClient.initMetadata(SalesForceWebServiceClient.java:205)
        at com.cmc.crmbridge.services.salesforce.SalesForceWebServiceClient.logon(SalesForceWebServiceClient.java:196)
        at com.cmc.crmbridge.services.salesforce.SalesForceWebServiceClient.ping(SalesForceWebServiceClient.java:293)
        at com.cmc.crmbridge.services.salesforce.TestSalesForceWebServiceClient.testPing(TestSalesForceWebServiceClient.java:41)
Caused by: org.apache.cxf.binding.soap.SoapFault: UNKNOWN_EXCEPTION: Destination URL not reset. The URL returned from login must be set in the SforceService
        at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:70)
        at org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:35)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:220)

cheekychopscheekychops
I managed to get it working, using a property name of "org.apache.cxf.message.Message.ENDPOINT_ADDRESS" for the URL.
kgromitkgromit
Can you comment on how you got past the INVALID_LOGIN problem?  I'm getting that exception when using the CXF DynamicClientFactory but not when using Axis.