Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Webservice API call

New Here ,
May 13, 2010 May 13, 2010

I have been trying to make Webservice call to "https://webservice.exacttarget.com/etframework.wsdl" using coldfusion server 9.0 without much success. My code recognizes WSDL and it methods but When I call method it throws following error:

Web service operation Describe with parameters {{DESCRIBEREQUESTS={[Lcom.et.client.ObjectDefinitionRequest;@78b0e1}}} cannot be found.

Please suggest.....



MyCode CFM file code:

Package Class: "com.et.client"

<cfsilent>
    <cffunction name="head1" access="private" returntype="Any" output="false"
                hint="Return the header needed to make an Omniture web service request as a SOAPHeaderElement object">
        <cfargument name="strUsername" type="String" required="true" />
        <cfargument name="strSecret" type="String" required="true" />
        <cfscript>
            // Unique random number
            var strNonce = createUUID();
          
            var strCreated  = DateFormat(Now(),'YYYY-mm-dd H:mm:ss');
          
            var strPassword = arguments.strSecret;
           
            // Start to build header
            var objHeader = CreateObject("java", "org.apache.axis.message.SOAPHeaderElement");
            var nodeUserToken = "";
            var nodePassword = "";
            // Construct XML structure with code
            objHeader.init("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:Security");
            objHeader.setMustUnderstand(1);
            objHeader.setActor("");
            nodeUserToken = objHeader.addChildElement("wsse:UsernameToken");
            nodeUserToken.setAttribute("wsu:Id", "User");
            nodeUserToken.addChildElement("wsse:Username").setValue(arguments.strUsername);
            nodePassword = nodeUserToken.addChildElement("wsse:Password");
            nodePassword.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0##PasswordText");
            nodePassword.setValue(strPassword);
            nodeUserToken.addChildElement("wsse:Nonce").setValue(strNonce);
            nodeUserToken.addChildElement("wsu:Created").setValue(strCreated);
        </cfscript>
        <cfreturn objHeader />
    </cffunction>

    <cfscript>
        objHeader = head1("test", "emails@3");
        objService = CreateObject("webservice", "https://webservice.exacttarget.com/etframework.wsdl");
        objService.setHeader(objHeader);

                                definitionRequest =  createObject("java", "com.et.client.ObjectDefinitionRequest").init();
                                definitionRequest.setObjectType("Account");
                               
                                DefinitionRequestMsg  = StructNew();                               
                                defre = arraynew(1);
                                defre[1] =definitionRequest;
                               
                                DefinitionRequestMsg.DescribeRequests = JavaCast("com.et.client.ObjectDefinitionRequest[]",defre);
   </cfscript>

</cfsilent>
</br>
SubKey ::: <cfdump var="#sub.SubscriberKey#">
<br/>
<p>
Type ::: <cfdump var="#definitionRequest.getObjectType()#">
<br/>
<p>
DefinitionRequestMsg ::: <cfdump var="#DefinitionRequestMsg.DescribeRequests[1].ObjectType#">
<br/>

<p>
Methods ::: <cfdump var="#objService#">
<br/>
<cfscript>
objService.Describe(DefinitionRequestMsg);
resp = getSOAPResponse(objService);



OutPut:

SubKey :::  Jon_Doe 

Type :::  Account

DefinitionRequestMsg :::  Account

Methods ::: 

object of com.exacttarget.wsdl.partnerAPI.SoapBindingStub
Class Namecom.exacttarget.wsdl.partnerAPI.SoapBindingStub
Methods
MethodReturn Type
configure(com.exacttarget.wsdl.partnerAPI.ConfigureRequestMsg)com.exacttarget.wsdl.partnerAPI.ConfigureResponseMsg
create(com.exacttarget.wsdl.partnerAPI.CreateRequest)com.exacttarget.wsdl.partnerAPI.CreateResponse
delete(com.exacttarget.wsdl.partnerAPI.DeleteRequest)com.exacttarget.wsdl.partnerAPI.DeleteResponse
describe(com.exacttarget.wsdl.partnerAPI.DefinitionRequestMsg)com.exacttarget.wsdl.partnerAPI.DefinitionResponseMsg
execute(com.exacttarget.wsdl.partnerAPI.ExecuteRequest[])com.exacttarget.wsdl.partnerAPI.ExecuteResponseMsg
extract(com.exacttarget.wsdl.partnerAPI.ExtractRequest[])com.exacttarget.wsdl.partnerAPI.ExtractResponseMsg
getSystemStatus(com.exacttarget.wsdl.partnerAPI.SystemStatusRequestMsg)com.exacttarget.wsdl.partnerAPI.SystemStatusResponseMsg
perform(com.exacttarget.wsdl.partnerAPI.PerformRequestMsg)com.exacttarget.wsdl.partnerAPI.PerformResponseMsg
query(com.exacttarget.wsdl.partnerAPI.QueryRequestMsg)com.exacttarget.wsdl.partnerAPI.QueryResponseMsg
retrieve(com.exacttarget.wsdl.partnerAPI.RetrieveRequestMsg)com.exacttarget.wsdl.partnerAPI.RetrieveResponseMsg
schedule(com.exacttarget.wsdl.partnerAPI.ScheduleRequestMsg)com.exacttarget.wsdl.partnerAPI.ScheduleResponseMsg
update(com.exacttarget.wsdl.partnerAPI.UpdateRequest)com.exacttarget.wsdl.partnerAPI.UpdateResponse
versionInfo(com.exacttarget.wsdl.partnerAPI.VersionInfoRequestMsg)com.exacttarget.wsdl.partnerAPI.VersionInfoResponseMsg
Fields
FieldValue
java.lang.String ENDPOINT_ADDRESS_PROPERTYjavax.xml.rpc.service.endpoint.address
java.lang.String PASSWORD_PROPERTYjavax.xml.rpc.security.auth.password
java.lang.String SESSION_MAINTAIN_PROPERTYjavax.xml.rpc.session.maintain
java.lang.String USERNAME_PROPERTYjavax.xml.rpc.security.auth.username
Parent Class
object org.apache.axis.client.Stub
Class Nameorg.apache.axis.client.Stub
Methods
MethodReturn Type
_createCall()org.apache.axis.client.Call
_getCall()org.apache.axis.client.Call
_getProperty(java.lang.String)java.lang.Object
_getPropertyNames()java.util.Iterator
_getService()javax.xml.rpc.Service
_setProperty(java.lang.String, java.lang.Object)void
addAttachment(java.lang.Object)void
clearAttachments()void
clearHeaders()void
extractAttachments(org.apache.axis.client.Call)void
getAttachments()java.lang.Object[]
getHeader(java.lang.String, java.lang.String)org.apache.axis.message.SOAPHeaderElement
getHeaders()org.apache.axis.message.SOAPHeaderElement[]
getPassword()java.lang.String
getPortName()javax.xml.namespace.QName
getResponseHeader(java.lang.String, java.lang.String)org.apache.axis.message.SOAPHeaderElement
getResponseHeaders()org.apache.axis.message.SOAPHeaderElement[]
getTimeout()int
getUsername()java.lang.String
removeProperty(java.lang.String)java.lang.Object
setHeader(java.lang.String, java.lang.String, java.lang.Object)void
setHeader(org.apache.axis.message.SOAPHeaderElement)void
setMaintainSession(boolean)void
setPassword(java.lang.String)void
setPortName(javax.xml.namespace.QName)void
setPortName(java.lang.String)void
setTimeout(int)void
setUsername(java.lang.String)void



The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.


The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request

Web service operation Describe with parameters {{DESCRIBEREQUESTS={[Lcom.et.client.ObjectDefinitionRequest;@78b0e1}}} cannot be found.

The error occurred in /Users/bgogineni/ColdFusion/wwwroot/ET/index2.cfm: line 84
82 : <br/> 83 : <cfscript> 
84 :  objService.Describe(DefinitionRequestMsg); 85 :  resp = getSOAPResponse(objService); 86 :

Resources:  
Browser Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9
Remote Address 127.0.0.1
Referrer 
Date/Time 13-May-10 10:27 PM
Stack Trace
at cfindex22ecfm949006999.runPage(/Users/bgogineni/ColdFusion/wwwroot/ET/index2.cfm:84)                 

coldfusion.xml.rpc.ServiceProxy$ServiceMethodNotFoundException: Web service operation Describe with parameters {{DESCRIBEREQUESTS={[Lcom.et.client.ObjectDefinitionRequest;@78b0e1}}} cannot be found. at coldfusion.xml.rpc.ServiceProxy.invokeImpl(ServiceProxy.java:256) at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:154) at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:2360) at cfindex22ecfm949006999.runPage(/Users/bgogineni/ColdFusion/wwwroot/ET/index2.cfm:84) at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231) at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416) at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65) at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:363) at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48) at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40) at coldfusion.filter.PathFilter.invoke(PathFilter.java:87) at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70) at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:74) 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.filter.CachingFilter.invoke(CachingFilter.java:53) at coldfusion.CfmServlet.service(CfmServlet.java:200) at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89) at jrun.servlet.FilterChain.doFilter(FilterChain.java:86) 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:286) at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543) at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172) 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)


Debugging Information
ColdFusion Server Enterprise9,0,0,251028
Template/ET/index2.cfm
Time Stamp13-May-10 10:27 PM
LocaleEnglish (US)
User AgentMozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.9) Gecko/20100315 Firefox/3.5.9
Remote IP127.0.0.1
Host Namelocalhost


Execution Time

Total TimeAvg TimeCountTemplate
15 ms15 ms1top level /Users/bgogineni/ColdFusion/wwwroot/ET/index2.cfm
14 msSTARTUP, PARSING, COMPILING, LOADING, & SHUTDOWN
29 msTOTAL EXECUTION TIME
red = over 250 ms average execution time 


Exceptions

22:27:34.034 - Application Exception - in /Users/bgogineni/ColdFusion/wwwroot/ET/index2.cfm : line 84
    Web service operation Describe with parameters {{DESCRIBEREQUESTS={[Lcom.et.client.ObjectDefinitionRequest;@78b0e1}}} cannot be found.    



Thanks

-GBK



8.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 24, 2010 May 24, 2010

Did you find a solution to this issue?

Was wondering if your authentication is working, and if it is, are you using the native version of AXIS that ships with CF9? What version is that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 31, 2010 May 31, 2010

No, I spent lot of time with no sucess.

Now I understand why Adobe Coldfusion is less adapative. No one from coldfusion product team attempted to answer.

Also there is no documentation on authentication and error codes. If Coldfusion team is looking into it, please open your heart/time and provide some guidence.

Thanks,

-GBK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 02, 2010 Aug 02, 2010

Heya,

I've just commenced work on an integration project requiring ExactTarget API access to a CRM application built in CF. Decided to do a quick online search for code examples before tackling it myself and came across this post. I haven't given the following page's example code a test run myself but will be in the next day or so. Until then, check this page out and see if that sheds some light on the matter.

Off the top my head and based on the ExactTarget API documentation I've read thus far I'd say its safe to conclude you're problem can be fixed since there is no reason for ColdFusion to be unable to communicate with ExactTarget's API. The API supports Apache AXIS and Java, both of which are already built-in to ColdFusion. Apache AXIS is the Java based webservice implementation ColdFusion uses for serving and connecting webservices so in theory it shouldn't be a battle getting the two to cooperate. You're not using CF's <CFINVOKE> or createObject() method of handling webservices but instead going for a Java based SOAP method which may be the cause of your issues as I don't know if that way would be going through AXIS but I'd assume it would. I'll post back here if the linked page below doesn't work and I'm able to work it out.

http://paulalkema.com/post.cfm/how-to-subscribe-a-user-in-exact-target-via-their-api

A workaround option would be to focus on the Apache AXIS version used in your CF9 installation and ensure it is a supported build, otherwise you can update CF9's Apache AXIS installation yourself. I'll be giving this a go if I run into problems so will let you know.

Cheers,

Pete - googleitics @ RIAForge.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2011 Jun 27, 2011

Hi,

Any success on implementing Exact Target API using Coldfusion.

I have no luck on this, would highly appreciate if I get any help.

Thanks

Balbir

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 27, 2011 Jun 27, 2011

I did not but someone else at the same company did - I believe he did find a

way with Javi to do the authentication piece and then is using soap

envelopes to do the other part.

Where are you stuck at?

Dan

Dan O'Keefe

Tripoint Technologies

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2011 Jun 27, 2011

Thanks for the quick reply.

I used the code in the above posting.

I am stuck at  the bolded line.

definitionRequest =  createObject("java", "com.et.client.ObjectDefinitionRequest").init();

How do I use a java class in my coldfusion code?

Package Class: "com.et.client"


<cfsilent>
    <cffunction name="head1" access="private" returntype="Any" output="false"
                hint="Return the header needed to make an Omniture web service request as a SOAPHeaderElement object">
        <cfargument name="strUsername" type="String" required="true" />
        <cfargument name="strSecret" type="String" required="true" />
        <cfscript>
            // Unique random number
            var strNonce = createUUID();
         
            var strCreated  = DateFormat(Now(),'YYYY-mm-dd H:mm:ss');
         
            var strPassword = arguments.strSecret;
          
            // Start to build header
            var objHeader = CreateObject("java", "org.apache.axis.message.SOAPHeaderElement");
            var nodeUserToken = "";
            var nodePassword = "";
            // Construct XML structure with code
            objHeader.init("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-sec ext-1.0.xsd", "wsse:Security");
            objHeader.setMustUnderstand(1);
            objHeader.setActor("");
            nodeUserToken = objHeader.addChildElement("wsse:UsernameToken");
            nodeUserToken.setAttribute("wsu:Id", "User");
            nodeUserToken.addChildElement("wsse:Username").setValue(arguments.str Username);
            nodePassword = nodeUserToken.addChildElement("wsse:Password");
            nodePassword.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token -profile-1.0##PasswordText");
            nodePassword.setValue(strPassword);
            nodeUserToken.addChildElement("wsse:Nonce").setValue(strNonce);
            nodeUserToken.addChildElement("wsu:Created").setValue(strCreated);
        </cfscript>
        <cfreturn objHeader />
    </cffunction>

    <cfscript>
        objHeader = head1("test", "emails@3");
        objService = CreateObject("webservice", "https://webservice.exacttarget.com/etframework.wsdl");
        objService.setHeader(objHeader);

                                definitionRequest =  createObject("java", "com.et.client.ObjectDefinitionRequest").init();
                                definitionRequest.setObjectType("Account");
                              
                                DefinitionRequestMsg  = StructNew();                              
                                defre = arraynew(1);
                                defre[1] =definitionRequest;
                              
                                DefinitionRequestMsg.DescribeRequests = JavaCast("com.et.client.ObjectDefinitionRequest[]",defre);
   </cfscript>

</cfsilent>

Header ::: <cfdump var="#objHeader#">
<br/>

<p>
Methods ::: <cfdump var="#objService#">

Thanks

Balbir

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 04, 2011 Jul 04, 2011

Hi BalbirRao123,

This is a little bit of tricky. Please follow the process, I guess your problem will be solved.

1. Write the below code in a test page and execute it in your server.

<cfscript>
    wsdlObject = createObject("webservice", "https://webservice.exacttarget.com/etframework.wsdl");
    WriteDump(wsdlObject);
</cfscript>

2. It will create one folder with a random name, for example 'WS-1150478675' under "ColdFusion9/stubs/" directory. This will contain all class files referenced in the wsdl.

3. You need to use this path ("ColdFusion9/stubs/WS-1150478675") to create class path in CF admin.

OR you can copy the folder inside the "ColdFusion9/stubs/WS-1150478675" directory and placed in a new directory (let say "D:/TestStub/")

4. Then you have to set up theclass path in coldfusion adminstartor
    
The classpath creation can be done at:
    CF Administrator -> Server Setting -> Java and JVM -> ColdFusion Class Path -> Full path to 'TestStub' or 'WS-1150478675'  folder.

     e.g - "D:\TestStub"

5. Restart the coldfusion application server.

6. Write the following code.

<cfscript>
    wsdlObject = createObject("webservice", "https://webservice.exacttarget.com/etframework.wsdl");
    WriteDump(wsdlObject);
    x = createObject("java", "com.exacttarget.wsdl.partnerAPI.ConfigureRequestMsg");
    WriteDump(x);
</cfscript>

Now it will work. When you dump the variable you can able to see some method like "setConfigurations", using that you have to set the parameter for the API call.

Thanks

Upendra

NOTE:- Please make sure to restart the coldfusion application server after adding the class path.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 11, 2011 Jul 11, 2011

Hello Upendra,

Thanks for your info. I tried everything you mentioned but, I still can't

move forward with Invoke method.

I get following error:

coldfusion.xml.rpc.ServiceProxy$ParameterNameNotFoundException: Web

service parameter name parameters cannot be found in the provided

parameters .

at coldfusion.xml.rpc.ServiceProxy.rearrangeParams(ServiceProxy.java:920)

at coldfusion.xml.rpc.ServiceProxy.invoke(ServiceProxy.java:140)

*Error at following line*

<cfinvoke

webservice = "#ws#"

method = "create" returnvariable="response">

<cfinvokeargument name="requestParam" value="#request1#">

</cfinvoke>

My Code:

<cfobject webservice="https://webservice.exacttarget.com/etframework.wsdl" name="ws">

<cfset myUsername = "developer@" />

<cfset myPassword = "pass@123" />

<cfscript>

headerElement = createObject("java","org.apache.axis.message.SOAPHeaderElement");

headerElement.init("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "wsse:Security");

headerElement.addChildElement("wsse:UsernameToken" );

headerElement.getFirstChild().addChildElement("wsse:Username").setValue(myUsername);

mypass = headerElement.getFirstChild().addChildElement("wsse:Password");

mypass.setValue(myPassword);

mypass.setAttribute("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0##PasswordText");

ws.setHeader(headerElement);

sub = createObject("java","com.exacttarget.wsdl.partnerAPI.Subscriber");

sub.setEmailAddress("1222et@et.com");

sub.setSubscriberKey("1222.et.com");

request1= createObject("java", "com.exacttarget.wsdl.partnerAPI.CreateRequest");

CFSubscriberArray = ArrayNew(1);

CFSubscriberArray[1] = sub;

options1 = createObject("java", "com.exacttarget.wsdl.partnerAPI.CreateOptions");

request1.setOptions(options1);

arrJavaValue = JavaCast("com.exacttarget.wsdl.partnerAPI.APIObject[]",CFSubscriberArray);

request1.setObjects(arrJavaValue);

response = createObject("java", "com.exacttarget.wsdl.partnerAPI.CreateResponse");

</cfscript>

<!--

Request# <cfdump var="#request1#"><BR/>

<br/>

WS# <cfdump var="#ws#">

-->

<cfinvoke

webservice = "#ws#"

method = "create" returnvariable="response">

<cfinvokeargument name="requestParam" value="#request1#">

</cfinvoke>

Response Dump## <cfdump var="#response#">

<br/>

-GBK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 13, 2011 Jul 13, 2011

Hi GBK,

You are missing something while setting the parameter. So when you are setting the parameter value make sure that it is the type specified in the class.

Always create a java object even if for string type.

Thanks

Upendra

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 13, 2011 Jul 13, 2011

I dont see any type in cfinvoke tag.

<cfinvokeargument

    name="argument name" 
    value="argument value" 
    omit = "yes|no">

Here is my working java, can you translate it.

     Subscriber subscriber = new Subscriber();

     subscriber.setEmailAddress("gbk@et.com");

     subscriber.setSubscriberKey(subscriber.getEmailAddress()); // unique identifier

     subscriber.setStatus(SubscriberStatus.Active);

     APIObject[] apiObjects = {subscriber};

     CreateRequest createRequest = new CreateRequest(new CreateOptions(), apiObjects);

     CreateResponse createResponse = stub.create(createRequest);

     System.out.println("Subscriber created in list ::: " + createResponse.getOverallStatus());

Thanks,

GBK

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 13, 2011 Jul 13, 2011

We do a lot of work with web service APIs using coldfusion.  A while ago, we decided it was much easier (especially when dealing with complex web service invocations) to switch to posting/receiving the raw XML SOAP messages in order to exchange data with the remote web service.  Ben Nadel has a great article that outlines what is involved:

http://www.bennadel.com/blog/1809-Making-SOAP-Web-Service-Requests-With-ColdFusion-And-CFHTTP.htm

What's more, you can use a lot of free/OSS tools to generate a template for the Request/Response SOAP messages, so it really just winds up being a matter of creating your XML in a cfsavecontent block and adding your variables in place of the sample text.  We use SOAPSonar from Crosscheck networks (http://www.crosschecknet.com/products/soapsonar.php) - they have a free "personal" edition that will parse a WSDL and generate the resulting XML SOAP messages that you can use as a template.

The only major issue is you have to watch out for the XML namespaces in the response that comes back from the web service.  ColdFusion (not surprisingly) has a major issue with extracting data using XMLSearch() from an XML node that includes a name space.  There are a couple of work-arounds - you could use a local-name() xpath method to perform a namespace-agnostic search, or you could use regular expressions to just strip all the namespace data out of the XML and parse using ColdFusion.

Anyway, the implementation winds up looking something like this:

<!--- build Soap XML --->

<cfsavecontent variable="sSOAPBody">

<cfoutput>

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

     <myMethod>

          <firstArgument>#MyValue#</firstArgument>

     </myMethod>

</soap:Body>

</soap:Envelope>

</cfoutput>

</cfsavecontent>

<!--- Send SOAP data using CFHTTP --->

<cfhttp url="URL of Web service (e.g. .asmx, .cfc - no WSDL)" method="post">

<cfhttpparam type="header" name="SOAPAction" value="http://target_namespace_goes_here/method">

<cfhttpparam type="header" name="accept-encoding" value="no-compression">

<cfhttpparam type="xml" value="#trim(sSOAPBody)#">

</cfhttp>

<!--- Parse XML Response in CFHTTP.FileContent --->

...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 14, 2011 Jul 14, 2011

Hi Gbk_ET ,

Please look into below code that how to set the parameter value .

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

requestObject = createObject("java", "com.exacttarget.wsdl.partnerAPI.CreateRequest");

     apiObject = createObject("java", "com.exacttarget.wsdl.partnerAPI.APIObject");

          clientIDObject = createObject("java", "com.exacttarget.wsdl.partnerAPI.ClientID");

          clientIDObject.setClientID(createObject("java", "java.lang.Integer").init("120"));

          clientIDObject.setCreatedBy(createObject("java", "java.lang.Integer").init("121"));

          clientIDObject.setCustomerKey(createObject("java", "java.lang.String").init("121"));

          clientIDObject.setEnterpriseID(createObject("java", "java.lang.Long").init("121"));

          clientIDObject.setID(createObject("java", "java.lang.Integer").init("121"));

          clientIDObject.setModifiedBy(createObject("java", "java.lang.Integer").init("121"));

          clientIDObject.setPartnerClientKey(createObject("java", "java.lang.String").init("121"));

          clientIDObject.setPartnerUserKey(createObject("java", "java.lang.String").init("121"));

          clientIDObject.setUserID(createObject("java", "java.lang.Integer").init("121"));

     apiObject.setCorrelationID(createObject("java", "java.lang.String").init("121"));

          calendarObject = createObject("java", "java.util.Calendar").getInstance();

          calendarObject.set("2011", "7", "14");

     apiObject.setCreatedDate(calendarObject);

     apiObject.setCustomerKey(createObject("java", "java.lang.String").init("121"));

     apiObject.setID(createObject("java", "java.lang.Integer").init("121"));

     apiObject.setModifiedDate(calendarObject);

     apiObject.setObjectID(createObject("java", "java.lang.String").init("121"));

     apiObject.setObjectState(createObject("java", "java.lang.String").init("121"));

          ownerObject = createObject("java", "com.exacttarget.wsdl.partnerAPI.Owner");

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is just a code snipet. If you will set the parameter in this way it will work.

Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 31, 2011 Aug 31, 2011

@insuractive:

Can you please point me to some good examples of creating CFCs to recieve a SOAP Packet from a vendor? I have posted them and consumed outside WSDLs many times, but this is the first time a vendor wants to "push" to me. Here is the question I just asked Ben Nadel on his site:

Like you, I have "consumed" a lot of Web Services using CF. But now for the first time, a vendor will be posting their data to MY Web Service using SOAP. I know all the basics for creating the CFC and the appropriate settings. But what I can't find good examples or documentation about is...

"How are the different parts of the SOAP Envelope/Body parsed by the CFC?"

Where do the elements end up so I can access them in the CFC? I assume they are treated as arguments, but how do "dump" what is coming in so I can build the CFC properly to parse it?

This could be so brain-dead simple and automated in CF that I am simply over-thinking it. But I am just not making the connections at this point.

I figure it is going to take awhile for Ben to answer, so I thought I would try some other boards. Any help you can provide is much appreciated.

Thanks!
Troy

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 31, 2011 Aug 31, 2011

I guess my first question would be - if you are the web service provider, why is your vendor defining the interface for your web service?  I would just construct the web service as a CFC remote method and make the WSDL available to them - that way they can choose what method they like to consume the web service (SOAP, cfinvoke, URL, etc).  It shouldn't matter to your code.  CF shouold handle SOAP requests just like any other request - it should be the vendor's job (and a fairly easy one at that) to customize their application in order to produce the correct SOAP message to access your web service.  Remember the CF built-in web service run on SOAP, so it shouldn't take any work on your end to accept a SOAP XML message that is customized for your application.

If that doesn't clear things up and you still need to know how to go from a SOAP message and build a web service around it, I would suggest you look at <cfproperty> to build your complex data types as CF components and build your interface around that.  You should be able to use any tool that generates sample SOAP from a WSDL file to check your work.  Of course, if there are crazy namespaces involved, that gets much more complicated.

Worst case scenario - SOAP is just XML.  You could always just parse the request message and respond with an appropriate formatted XML SOAP response.  There wouldn't be a WSDL, but if they already have the SOAP message ready they don't really need one.

Anyway, hope that helps.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 31, 2011 Aug 31, 2011

That does help a bit...thanks. I guess the unique thing I am struggling with is that they are sending me an xml packet of their own spec as the SOAP body. I only need a way to get the body of the SOAP from their WSDL post to me -- I have already written the parser for that packet xml. But I don't know where to look in the SOAP for the body that contains it. Do I simply give them an argument name to post it to, and they parametrize that?

I ask because every example I see of posting to a Web Service, and the way I do it as well, is to have a cfhttpparam of type="xml", with no "name" argument, and a value of my SOAP string. So if someone posts to me like that, what argument contains that unnamed cfhttpparam?

Thanks,

Troy

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 31, 2011 Aug 31, 2011

Good question - I'm not really sure how that type="xml" shows up in CF.  My suggestion would be to perform a test CFHTTP post to a page where you dump out the REQUEST scope (or just the FORM scope might work) and see how the variable names come across.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 09, 2011 Sep 09, 2011

So after testing, it turns out that the "xml" variable is the same as the "body" one -- it is just the "content" of the post. XML simply sets the file/content type to XML for you instead of text etc.

And the best way to see "all this stuff" during testing in the "receiver" file is by using the GetHTTPRequestData() method.

Thanks,

Troy

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 12, 2013 Mar 12, 2013

!!!!! GAH !!!!!  THAT IS SO VERY SCARY

Do not do what #7 in this thread listed above.  YES, it is extremely easy to make everything work, but what happens when the web service changes?  What happens if the webservice changes so much that it voids out all the work that you have done?  You will have to recopy and paste each time it changes.

There is a better way...

On the Webservice Object, behind the scenes deep in the java, there is a class loader object that has reference to the location in the /{coldfusion_base}/stubs/{webservicename} where you classes are stored, and you can create instances of those classes through this object.


Here is how you get to it:

local.webservice = CreateObject("webservice", arguments.url);

local.classLoader = local.webservice.getClass().getProtectionDomain().getClassLoader();

Now you would want to load the class you were trying to make, i will use one of your examples:

local.ConfigureRequestMsgClass = local.classLoader.loadClass('com.exacttarget.wsdl.partnerAPI.ConfigureRequestMsg');

Now you will want to get an instance of that class:

local.ConfigureRequestMsg = local.ConfigureRequestMsgClass.newInstance();

You now have an instance of the 'com.exacttarget.wsdl.partnerAPI.ConfigureRequestMsg' class, without ever having to deal with restarting coldfusion, without moving files, without dealing with JVM settings, without any issues with future compatibility.

I ended up making a component that wraps around your webservice object that can help you.

Note: I named things really ugly so that it did not conflict with the OnMissingMethod so you can call the functions directly from the webservice to this object.

When trying to create a new instance, use the createObject() function on here with the fullyQualifiedPath to make a new instance, but other than that, treat it just like a normal webservice.

component accessors="true"

{

    property name="__webservice__";

    variables.__webserviceKey__ = "__webservice__";

    variables.__classes__ = {};

    public function init(required url)

    {

        variables.__classes__ = {};

        __createWebservice__(ArgumentCollection = arguments);

        return this;

    }

    private function __hasWebservice__()

    {

        return StructKeyExists(variables, variables.__webserviceKey__) && !IsNull(variables[variables.__webserviceKey__]);

    }

    private function __createWebservice__(required url)

    {

        set__webservice__(CreateObject("webservice", arguments.url));

        return this;

    }

    private function __getClassLoader__(required webservice)

    {

        return arguments.webservice.getClass().getProtectionDomain().getClassLoader();

    }

    private function __createClass__(required fullyQualifiedPath)

    {

        local.classLoader = __getClassLoader__(get__webservice__());

        variables.__classes__[arguments.fullyQualifiedPath] = local.classLoader.loadClass(arguments.fullyQualifiedPath);

        return variables.__classes__[arguments.fullyQualifiedPath];

    }

    public function createObject(required fullyQualifiedPath)

    {

        if(!StructKeyExists(variables.__classes__, arguments.fullyQualifiedPath))

        {

            __createClass__(ArgumentCollection = arguments);

        }

        return variables.__classes__[arguments.fullyQualifiedPath].newInstance();

    }

    public function onMissingMethod(required missingMethodName, required missingMethodArguments)

    {

        local.webservice = get__webservice__();

        return Evaluate("local.webservice.#missingMethodName#(ArgumentCollection = arguments.missingMethodArguments)");

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 01, 2014 Dec 01, 2014

Dear All Technology Expert's,

I have a query related to Coldfusion SOAP services, that is most commonly asked in all the forum's but NONE of them has got answer.

If there is NO solution so I think Adobe has to come up with some patches so developer can able to do some customization.

I like to share with you all, in all other language ( PHP, JAVA, .NET etc) this option is available and you can customize the error.

Ok let me again explain the very basic error:

SOAP Request:

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Header/>

   <soapenv:Body>

    

   </soapenv:Body>

</soapenv:Envelope>

SOAP Response:

  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

      <soapenv:Fault>

         <faultcode>soapenv:Server.userException</faultcode>

         <faultstring>java.lang.Exception: Body not found.</faultstring>

         <detail>

            <ns1:stackTrace xmlns:ns1="http://xml.apache.org/axis/">java.lang.Exception: Body not found.

  at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:121)...</ns1:stackTrace>

            <ns2:hostname xmlns:ns2="http://xml.apache.org/axis/">Coldfusion Error</ns2:hostname>

         </detail>

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

HOW we can customize the error, in all other languages you can simple customize the error like

Other languages SOAP response:

  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

      <soapenv:Fault>

         <faultcode>BODY_NOT_FOUND</faultcode>

         <faultstring>Body is missing in your request</faultstring>

        

      </soapenv:Fault>

   </soapenv:Body>

</soapenv:Envelope>

But the same is NOT possible in Coldfusion, right?

AS you know it is vulnerability to display exception messages in the response.

We are developing this web service to access  from other language website (PHP, .NET).

We are also planning to upgrade server the Coldfusion 11, but do you think there is any solution with latest Coldfusion version.

Please response only if you know about these issue's or solution. 

Thanks

Niyaz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 01, 2014 Dec 01, 2014
LATEST

@Niyaz

You will gain little by asking the same question in multiple places in the forum. In fact, many might consider it annoying or even spam.

This question is being discussed in the thread that HaroonTyagi started. (Are you HaroonTyagi, by chance?) I will post an answer there shortly.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources