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

Using CreateObject for Webservice with username and password

New Here ,
Dec 10, 2007 Dec 10, 2007

Copy link to clipboard

Copied

When using createObject() to call a web service how do I pass in the user name and password required by the service?

If I do a cfdump on the webservice object I see it has setUserName() and setPassword() methods but they don't seem to be working.

I also see there are properties named "USERNAME_PROPERTY" and "PASSWORD_PROPERTY" but I can't seem to modify them in code. I suppose they are protected.

example:
ws = createObject("webservice", " http://url.to/wsdl.xml", "serviceport");
ws.setUserName("myawesomeusername");
ws.setPassword("myawesomepassword");
myReturn = ws.serviceMethodCall("bla");
TOPICS
Advanced techniques

Views

515

Translate

Translate

Report

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 ,
Jan 08, 2008 Jan 08, 2008

Copy link to clipboard

Copied

For anyone that encounters the same issue/question; apparently you can't apply a username/password to the object call like you can when using <cfinvoke> to make a web service call.

FYI Adobe: this is VERY limiting, I have to use a web service that uses in/out parameters which to the best of my knowledge requires the use of createObject() but at the same time the web service requires a username and password which I can only do with <cfinvoke>. Looks like I will be writing a compiled custom tag just for a workaround.

Votes

Translate

Translate

Report

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
Advisor ,
Jan 08, 2008 Jan 08, 2008

Copy link to clipboard

Copied

quote:

Originally posted by: MACRStockHolder
For anyone that encounters the same issue/question; apparently you can't apply a username/password to the object call like you can when using <cfinvoke> to make a web service call.

FYI Adobe: this is VERY limiting, I have to use a web service that uses in/out parameters which to the best of my knowledge requires the use of createObject() but at the same time the web service requires a username and password which I can only do with <cfinvoke>. Looks like I will be writing a compiled custom tag just for a workaround.




According to the docs you can provide a username and password by passing a struct containing these items to CreateObject
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_c-d_18.html#4514398

If you like cfinvoke use it. You can get return values by using the returnVariable argument. I would assume mutliple output parameters would be returned in a struct.
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_i_10.html#4001127

Votes

Translate

Translate

Report

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 ,
Jan 08, 2008 Jan 08, 2008

Copy link to clipboard

Copied

Thanks for the reply. I forgot to mention this, I am stuck using CFMX 7. Looks like what I need is in CFMX 8.

Votes

Translate

Translate

Report

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
Advisor ,
Jan 08, 2008 Jan 08, 2008

Copy link to clipboard

Copied

LATEST
Options:
1. Use the cfinvoke tag
2. setup the web service's username and password in the CF administator and use CreateObject function

Either option should work on CF7.

Votes

Translate

Translate

Report

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
Documentation