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

Unable to Consume Windows Communication Foundation Web Service with Basic Authentication

Advisor ,
May 19, 2010 May 19, 2010
I have a problem when trying to consume a web service based on the Windows Communication Foundation (WCF) using ColdFusion 8.0.1 on Windows 2003/IIS.  The web service in question requires basic authentication.  Both the CF and WCF web service servers are in house.  My goal is to expose some business logic written in WCF to my CF web site.

I receive the following ColdFusion error message when attempting to consume the service:
Cannot generate stub objects for web service invocation.
Name: http://example.com/MyService.svc?wsdl. WSDL: http://example.com/MyService.svc?wsdl. java.io.IOException: Server returned HTTP response code: 401 for URL: http://example.com/MyService.svc?xsd=xsd0 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.



I have examined the web logs from the web service machine and it appears that the request to the WSDL URL specified in the CFOBJECT tag includes the required basic authentication user name and password.  WCF web service WSDL information is not contained in a single file.  The WSDL contains multiple import instructions that require additional URLs to be requested.  For example MyService.svc?wsdl would contain an instruction to import a file at MyService.svc?xsd=xsd0. This appears to be the cause of the failure.  The username and password is not being supplied to the requests for the additional files.


Here are snippets from the IIS logs on the WCF web serivce machine:

This request succeeded, the "200" is HTTP OK:
2010-05-19 16:49:16 W3SVC1 10.10.10.10 GET /MyService.svc wsdl 80 my_user_name 10.10.10.11 - 200 0 0

This request failed, the "401" indicates that the request did not include the required authentication info:
2010-05-19 16:49:16 W3SVC1 10.10.10.10 GET /MyService.svc xsd=xsd0 80 - 10.10.10.11 Java/1.6.0_04 401 2 2148074254


I have attempted to use the wsdl2javaArgs attribute of the CFOBJECT tag to specify the username and password but this does not change CF's behavior.  Here is my CF code:



Has anyone run into this before and have a solution or workaround?  Is there any additional information I can provide?

Thanks.
TOPICS
Advanced techniques
1.3K
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
Advisor ,
May 19, 2010 May 19, 2010
LATEST

Here is the CF code to consume the service

<cfset basicAuthUserId="my_user_name" />
<cfset basicAuthPassword="my_password" />
<cfobject name="variables.testService" type="webservice" webservice="http://example.com/MyService.svc?wsdl" username="#basicAuthUserId#" password="#basicAuthPassword#" refreshwsdl="yes" wsdl2javaArgs="-U #basicAuthUserId# -P #basicAuthPassword#" />

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