RE: WCF Proxy Server settings not working
- From: Clint <cmueller@xxxxxxxxxxxxx>
- Date: Wed, 1 Oct 2008 08:46:01 -0700
Hi Steven,
Thanks for your reply! I looked into what you suggested about the user info,
and found that when I checked the Environment.UserName property under
approach 2, I see my username. When I check that property under approach 1,
it shows ASPNET. I changed the anonymous username in IIS (5.1 under XP) to a
domain account that has rights to the proxy server, and reran my tests. Still
the same thing - ASPNET shows up as the user.
I've attached the code I'm using below, as well as the relevent sections in
my Web.config file:
In Test Project:
[Test]
public void GetFullIndustryProfile()
{
// ResearchClient is the top level "Research" WCF service that is
referenced by a Service Reference
using (ResearchClient client = new ResearchClient())
{
IndustryResearchResponse response = client.GetIndustryProfile(1234);
// clipped Asserts
}
}
In "Research":
public IndustryResearchResponse GetMarketResearchInformation(int id)
{
// This is the intermediate wrapper and is referenced directly
ThirdPartyResearchWrapper wrapper = new ThirdPartyResearchWrapper();
IndustryResearchResponse profile = wrapper.GetIndustryProfile(id);
// clipped out code that does work on the resulting data
return profile
}
In "ThirdPartyResearchWrapper":
public IndustryResearchResponse GetIndustryProfile(int id)
{
// Create's a call to the external MarketResearch web service
using (MarketResearchSoapClient services = new MarketResearchSoapClient())
{
// I can comment the following line out and it doesn't make a
difference
services.ClientCredentials.Windows.ClientCredential =
ServiceAuthorization.GetServiceCredentials();
// This line throws the 407 - proxy authentication required message
IndustryResearchResponse response = services.FindMarketProfileById(id);
// clipped out code that does work on the resulting data
return response;
}
}
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MarketResearchSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard" maxBufferSize="4194304"
maxBufferPoolSize="524288" maxReceivedMessageSize="4194304"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName"
algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IResearch" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="4194304"
maxReceivedMessageSize="4194304" messageEncoding="Text" textEncoding="utf-8"
useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="4194304"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"
/>
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true" algorithmSuite="Default"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/ResearchService/Research.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IResearch"
contract="ResearchService.IResearch" name="WSHttpBinding_IResearch">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="http://public.internet.site/MarketResearch.asmx"
binding="basicHttpBinding" bindingConfiguration="MarketResearchSoap"
contract="MarketResearchServices.MarketResearchSoap"
name="MarketResearchSoap" />
</client>
</system.serviceModel>
Thanks!
Clint
""Steven Cheng"" wrote:
Hi Clint,.
Based on your problem description, I understand that you're encountering a
proxy authentication issue when cosuming a remote servcie via WCF client,
correct?
I haven't researched the difference between webservice client and WCF
client yet. But based on my experience, since it works when you directly
call the "ThirdPartyResearchWrapper", but failed when you call it via
another local WCF service("Research") sevice, I think the problem is that
the "Research" service is not passing the correctly credentials for the
proxy authentication. Here is my analysis based on the topology of your
current service environment.
=============
Two approachs:
1. ClientApp----> "Research" Service (used the wrapper) ----> 3rd party
service
result: not work, proxy authentication error
2. ClientApp(directly use wrapper) ---> 3rd party service
result: works
==============
Since you've used " <defaultProxy useDefaultCredentials="true"> setting, we
know that in approach #1, it will use your application's running process
account to access the remote service(also proxy server), you can verify the
account.
In approach#2, since you access the remote 3rd party service via
intermediate "research service", therefore, the proxy authentication rely
on the security identity at "Research" service's web application context,
is it also using the same identity as the one in #1? I think this is what
you can try checking. If not, you can consider using the following means
to make the "Research" service use the specified account:
1. change the "Research" service's running process account(such as change
the IIS application pool identity)
2. You can use impersonate to programmtically make the certain
function/code running under a specify account
In addition, as you mentioned that
<<<<<<<<<<<<
I've tried hard-coding the login/password to our proxy server within
ThirdPartyResearchWrapper where it calls MarketResearch
would you show me the code you used?
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://support.microsoft.com/select/default.aspx?target=assistance&ln=en-us.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Thread-Topic: WCF Proxy Server settings not working
thread-index: AckjRwxoXqPAeJ7JQrSAWCIvDobtGA==
From: =?Utf-8?B?Q2xpbnQ=?= <cmueller@xxxxxxxxxxxxx>
Subject: WCF Proxy Server settings not working
Date: Tue, 30 Sep 2008 14:54:01 -0700
to
Hello,
I've been having a problem connecting to a standard ASMX file via WCF when
going through a proxy server. My setup is a little confusing, so I'll try
explain it first before the problem ...To
I have a series of services, some front-end interfaces (FE) for back-end
services (BE) that themselves may be an interface to a third party site.
simplify, say I have three services:all
1. Front-end "Research" service (WCF - SVC)
2. Back-end "ThirdPartyResearchWrapper" service (WCF - SVC)
3. Third party "MarketResearch" service (ASMX, sourced externally, not on
our intranet like (1) and (2))
Right now, Research has ThirdPartyResearchWrapper as a DLL reference.
ThirdPartyResearchWrapper has MarketResearch as a Service Reference (with
the applicable client binding information in the Web.config file).tests
Now, I have a library that contains a bunch of nUnit tests. I have two
in particular - one that tests out ThirdPartyResearchWrapper (as a DLLResearch's
reference), and one that tests out Research as a Service Reference. I have
the following in my config files for both the test library and in
web.config file:(via
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy usesystemdefault="False"
proxyaddress="http://[our proxy server's address]"
bypassonlocal="True" />
</defaultProxy>
</system.net>
The web site runs as a domain user that has internet access.
Now, if I run the test that goes directly to ThirdPartyResearchWrapper
the DLL link), my service call works just fine. If I run the test thatgoes
to Research (via Service Reference), I get "The remote server returned anabsolutely
unexpected response: (407) Proxy Authentication Required.".
I've tried hard-coding the login/password to our proxy server within
ThirdPartyResearchWrapper where it calls MarketResearch and I've made sure
the config file is visible to ThirdPartyResearchWrapper, all with
no luck. To make matters worse, when I had MarketResearch referencedinside
ThirdPartyResearchWrapper as a Web Service Reference, everything workedfine.
I don't want to go back to this route as eventually I'll need to implementa
SOAP extension, and that's far easier via WCF than the non-WCF way.on
I'd appreciate any help you can provide. I've pretty much wasted all day
this looking for answers online, and have come up dry.
Thanks!
Clint
- Follow-Ups:
- RE: WCF Proxy Server settings not working
- From: "Steven Cheng"
- RE: WCF Proxy Server settings not working
- References:
- WCF Proxy Server settings not working
- From: Clint
- RE: WCF Proxy Server settings not working
- From: "Steven Cheng"
- WCF Proxy Server settings not working
- Prev by Date: RE: Service Client Receives "Bad Request (Invalid Header Name)" Respon
- Next by Date: RE: WCF Proxy Server settings not working
- Previous by thread: RE: WCF Proxy Server settings not working
- Next by thread: RE: WCF Proxy Server settings not working
- Index(es):
Relevant Pages
|
Loading