CSoapSocketClientT and HTTP: 407 Access Denied error through Proxy Server

Discussion in 'ASP .Net Web Services' started by Dave Langley, Sep 3, 2003.

  1. Dave Langley

    Dave Langley Guest

    I'm using VC++ to write an VC++ unmanaged client to communicate to a C#.NET
    web service. I have the proxy class for the unmanaged client and it uses the
    default CSoapSocketClientT<> template as it's HTTP connection. This works
    fine until I start using a proxy server with authorization rather than a
    direct HTTP connection. I keep getting a 407 un-authorized response. I've
    have looked at both the CNTLMAuthObject and CBasicAuthObject objects in
    combination with the NegotiateAuth method but have had no luck.

    I have older VC++ clients that use the CInternetSession class and I'm able
    to set the proxy server authorization using the:

    pTSConnection->SetOption(INTERNET_OPTION_PROXY_USERNAME,strLoginName,
    lstrlen (strLoginName)) ;
    pTSConnection->SetOption(INTERNET_OPTION_PROXY_PASSWORD,strLoginPassword,
    lstrlen (strLoginPassword)) ;

    What I what is the CSoapSocketClientT<> equivalent of the
    CInternetSession.SetOption(INTERNET_OPTION_PROXY_USERNAME) and
    CInternetSession.SetOption(INTERNET_OPTION_PROXY_PASSWORD).

    Best Regards,

    Dave
    Dave Langley, Sep 3, 2003
    #1
    1. Advertising

  2. Dave Langley

    Simon Trew Guest

    Yes, I would certainly consider changing the template class just to see if
    it works (i.e. eliminate the fact that the proxy is incorrectly configured
    or auth details are incorrect). That being said, my experience is
    thatCSoapMSXMLInetClient is not as fast as others as it has to do a lot of
    COM. In practice though this is not a major time consumer in the app as a
    whole.

    "Igor Tandetnik" <> wrote in message
    news:...
    > Consider using CSoapWininetClient client instead, then you have access
    > to HINTERNET handles, in particular m_hInternet. Or
    > CSoapMSXMLInetClient, then you have access to IServerXMLHTTPRequest
    > interface pointer with its setProxy and setProxyCredentials methods.
    > --
    > With best wishes,
    > Igor Tandetnik
    >
    > "For every complex problem, there is a solution that is simple, neat,
    > and wrong." H.L. Mencken
    >
    > "Dave Langley" <> wrote in message
    > news:...
    > > I'm using VC++ to write an VC++ unmanaged client to communicate to a

    > C#.NET
    > > web service. I have the proxy class for the unmanaged client and it

    > uses the
    > > default CSoapSocketClientT<> template as it's HTTP connection. This

    > works
    > > fine until I start using a proxy server with authorization rather than

    > a
    > > direct HTTP connection. I keep getting a 407 un-authorized response.

    > I've
    > > have looked at both the CNTLMAuthObject and CBasicAuthObject objects

    > in
    > > combination with the NegotiateAuth method but have had no luck.
    > >
    > > I have older VC++ clients that use the CInternetSession class and I'm

    > able
    > > to set the proxy server authorization using the:
    > >
    > > pTSConnection->SetOption(INTERNET_OPTION_PROXY_USERNAME,strLoginName,
    > > lstrlen (strLoginName)) ;
    > >

    > pTSConnection->SetOption(INTERNET_OPTION_PROXY_PASSWORD,strLoginPassword
    > ,
    > > lstrlen (strLoginPassword)) ;
    > >
    > > What I what is the CSoapSocketClientT<> equivalent of the
    > > CInternetSession.SetOption(INTERNET_OPTION_PROXY_USERNAME) and
    > > CInternetSession.SetOption(INTERNET_OPTION_PROXY_PASSWORD).
    > >
    > > Best Regards,
    > >
    > > Dave
    > >
    > >
    > >

    >
    >
    Simon Trew, Sep 4, 2003
    #2
    1. Advertising

  3. Dave Langley

    Dave Langley Guest

    Also tried:

    vProxyServer.vt=VT_BSTR ;
    vProxyServer.bstrVal=SysAllocString(L"192.168.1.2:808") ;

    This doesn't cause the setProxy to crap out but the proxy redirection is
    ignored...


    "Dave Langley" <> wrote in message
    news:%...
    > Igor,
    > Using CSoapMSXMLInetClient looks like it might work and I have a VB
    > example working using MSXML4 library directly. However it seems to crap

    out
    > in VC++. The problem seems to be in passing in the name of the proxy

    server.
    > I'm using VARIANTS but do not seem to have any luck. Documentation for

    VC++
    > is non existent!!! Anyone got MSXML4 working in VC++ with proxy support?
    >
    >
    > // m_spHttpRequest set correctly earlier in function
    > IServerXMLHTTPRequest2 *pIServerXMLHTTPRequest=m_spHttpRequest ;
    >
    > VARIANT vProxyServer ;
    > VARIANT vByPassList ;
    >
    > vByPassList.vt=VT_ERROR ;
    > vByPassList.bstrVal=(BSTR)DISP_E_PARAMNOTFOUND ;
    >
    > vProxyServer.vt=VT_ARRAY|VT_BSTR;
    > SAFEARRAY *psa;
    > SAFEARRAYBOUND bounds={1,0};
    > psa=SafeArrayCreate(VT_BSTR,1,&bounds);
    > BSTR *bstrArray;
    > SafeArrayAccessData(psa,reinterpret_cast<void**>(&bstrArray));
    > bstrArray[0]=SysAllocString(L"192.168.1.2:808") ;
    > SafeArrayUnaccessData(psa);
    > vProxyServer.parray=psa;
    >
    > // craps out on this line.
    >

    pIServerXMLHTTPRequest->setProxy(SXH_PROXY_SET_PROXY,vProxyServer,vByPassLis
    > t) ;
    >
    >
    >
    > Best Regards,
    >
    > Dave.
    >
    >
    > "Simon Trew" <ten.egnaro@werts> wrote in message
    > news:u6XMQ$...
    > > Yes, I would certainly consider changing the template class just to see

    if
    > > it works (i.e. eliminate the fact that the proxy is incorrectly

    configured
    > > or auth details are incorrect). That being said, my experience is
    > > thatCSoapMSXMLInetClient is not as fast as others as it has to do a lot

    of
    > > COM. In practice though this is not a major time consumer in the app as

    a
    > > whole.
    > >
    > > "Igor Tandetnik" <> wrote in message
    > > news:...
    > > > Consider using CSoapWininetClient client instead, then you have access
    > > > to HINTERNET handles, in particular m_hInternet. Or
    > > > CSoapMSXMLInetClient, then you have access to IServerXMLHTTPRequest
    > > > interface pointer with its setProxy and setProxyCredentials methods.
    > > > --
    > > > With best wishes,
    > > > Igor Tandetnik
    > > >
    > > > "For every complex problem, there is a solution that is simple, neat,
    > > > and wrong." H.L. Mencken
    > > >
    > > > "Dave Langley" <> wrote in message
    > > > news:...
    > > > > I'm using VC++ to write an VC++ unmanaged client to communicate to a
    > > > C#.NET
    > > > > web service. I have the proxy class for the unmanaged client and it
    > > > uses the
    > > > > default CSoapSocketClientT<> template as it's HTTP connection. This
    > > > works
    > > > > fine until I start using a proxy server with authorization rather

    than
    > > > a
    > > > > direct HTTP connection. I keep getting a 407 un-authorized response.
    > > > I've
    > > > > have looked at both the CNTLMAuthObject and CBasicAuthObject objects
    > > > in
    > > > > combination with the NegotiateAuth method but have had no luck.
    > > > >
    > > > > I have older VC++ clients that use the CInternetSession class and

    I'm
    > > > able
    > > > > to set the proxy server authorization using the:
    > > > >
    > > > >

    pTSConnection->SetOption(INTERNET_OPTION_PROXY_USERNAME,strLoginName,
    > > > > lstrlen (strLoginName)) ;
    > > > >
    > > >

    pTSConnection->SetOption(INTERNET_OPTION_PROXY_PASSWORD,strLoginPassword
    > > > ,
    > > > > lstrlen (strLoginPassword)) ;
    > > > >
    > > > > What I what is the CSoapSocketClientT<> equivalent of the
    > > > > CInternetSession.SetOption(INTERNET_OPTION_PROXY_USERNAME) and
    > > > > CInternetSession.SetOption(INTERNET_OPTION_PROXY_PASSWORD).
    > > > >
    > > > > Best Regards,
    > > > >
    > > > > Dave
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
    Dave Langley, Sep 4, 2003
    #3
  4. Dave Langley

    Kim Gräsman Guest

    Dave,

    > vProxyServer.vt=VT_BSTR ;
    > vProxyServer.bstrVal=SysAllocString(L"192.168.1.2:808") ;
    > This doesn't cause the setProxy to crap out


    When you say "crap out", what do you mean, exactly?

    > vProxyServer.vt=VT_ARRAY|VT_BSTR;


    I think this should be a SAFEARRAY of VARIANT, since clients are generally
    scripting languages, who can only produce this kind of SAFEARRAY.

    I'm not familiar with ServerXMLHTTPRequest - does the docs say it takes an
    array?

    > > vByPassList.vt=VT_ERROR ;
    > > vByPassList.bstrVal=(BSTR)DISP_E_PARAMNOTFOUND ;


    That doesn't look right... Try:

    vByPassList.vt = VT_ERROR;
    vByPassList.scode = DISP_E_PARAMNOTFOUND;

    Please ping back with more details,
    Kim
    Kim Gräsman, Sep 4, 2003
    #4
  5. Dave Langley

    Dave Langley Guest

    Thanks for looking at this Kim,

    All the documentation says:

    varProxyServer [in, optional]
    The name of a proxy server or a list of proxy server names.

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/htm/xml_mth_sz_65q1.asp

    When I say craps out it causes an UnknownException.

    Best Regards,

    Dave


    "Kim Gräsman" <> wrote in message
    news:...
    > Dave,
    >
    > > vProxyServer.vt=VT_BSTR ;
    > > vProxyServer.bstrVal=SysAllocString(L"192.168.1.2:808") ;
    > > This doesn't cause the setProxy to crap out

    >
    > When you say "crap out", what do you mean, exactly?
    >
    > > vProxyServer.vt=VT_ARRAY|VT_BSTR;

    >
    > I think this should be a SAFEARRAY of VARIANT, since clients are generally
    > scripting languages, who can only produce this kind of SAFEARRAY.
    >
    > I'm not familiar with ServerXMLHTTPRequest - does the docs say it takes an
    > array?
    >
    > > > vByPassList.vt=VT_ERROR ;
    > > > vByPassList.bstrVal=(BSTR)DISP_E_PARAMNOTFOUND ;

    >
    > That doesn't look right... Try:
    >
    > vByPassList.vt = VT_ERROR;
    > vByPassList.scode = DISP_E_PARAMNOTFOUND;
    >
    > Please ping back with more details,
    > Kim
    >
    >
    Dave Langley, Sep 4, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George
    Replies:
    1
    Views:
    14,308
    shijobaby
    Feb 6, 2010
  2. George
    Replies:
    0
    Views:
    486
    George
    Oct 30, 2003
  3. Nuzhat Parveen via .NET 247

    407:Proxy authentication error while try to access Web Service published on internet

    Nuzhat Parveen via .NET 247, Jul 4, 2004, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    338
    Durgaprasad Gorti[MSFT]
    Jul 6, 2004
  4. Scott O'Donnell

    request failed with HTTP status 407: Proxy Authentication Required

    Scott O'Donnell, Feb 14, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    630
    Scott O'Donnell
    Feb 14, 2005
  5. Replies:
    1
    Views:
    826
Loading...

Share This Page