1

The client has provided me with their location to .net asmx webservice. I created a library which I use in my web application to communicate with their web service.

In my library, I created a web reference to the asmx

This is my code to invoke their service

using (vendorproxy.vendorproxy wsProxy = new vendorproxy.vendorproxy())
{
    wsProxy.Credentials = new System.Net.NetworkCredential(uname, pwd);

    using (Stream xmlStream = xmlUtil.GenerateStreamFromString(
        wsProxy.GetData(index)))
    {
        //
    }
}

public Stream GenerateStreamFromString(String inputString)
{
    byte[] bytes = UTF8Encoding.UTF8.GetBytes(inputString);
    MemoryStream strm = new MemoryStream();
    strm.Write(bytes, 0, bytes.Length);
    return strm;
}

The client developed a test app to test their service and it works. However my application when deployed on their system fails. I cannot step through the code as the client has not exposed the service outside of their network. This was developed by them providing sample output via xml file and their wsdl only.

The exception details:

at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)     
at System.Net.HttpWebRequest.GetRequestStream()     
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(
   String methodName, Object[] parameters)     

App.config of my class library that has the web ref to the service and one that does the invoking. The class library is used by my web app

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="clientService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
        </sectionGroup>
    </configSections>
    <system.serviceModel>
        <bindings />
        <client />
    </system.serviceModel>
    <applicationSettings>
        <clientService.Properties.Settings>
            <setting name="clientService_client_client" serializeAs="String">
                <value>http://localhost:2362/client.asmx</value>
            </setting>
        </clientService.Properties.Settings>
    </applicationSettings>
</configuration>

Solved: This worked after i modified my original code from

using (vendorproxy.vendorproxy wsProxy = new vendorproxy.vendorproxy())
{
    wsProxy.Credentials = new System.Net.NetworkCredential(uname, pwd);
}

TO

using (vendorproxy.vendorproxy wsProxy = new vendorproxy.vendorproxy())
{
    wsProxy.Credentials = new System.Net.NetworkCredential(uname, pwd);
    wsProxy.URL = [correct asmx location read from config file]
    //not sure why it would not automatically pick up from config file. 
}
Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
user644702
  • 11
  • 1
  • 1
  • 3

2 Answers2

1

You may be having problems with your proxy getting to an external address you may need to add something like this to your config.

  <system.net>
    <defaultProxy>
      <proxy
          autoDetect = "true" />
    </defaultProxy>
  </system.net>

Regards

Iain
  • 6,392
  • 2
  • 30
  • 50
  • @lain: My web app uses a class library, which connects to the webservice project. And this is my app.config from the class library that has a web ref to the service – user644702 Mar 04 '11 at 13:35
0

My best guess (based off the limited exception information):

You should be updating the location used to connect to the webservice when you deploy it on their server(s).

The location is usually a URI/URL inside of the web.config or app.config.

Tony Abrams
  • 4,505
  • 3
  • 25
  • 32
  • When deployed on thier system. I updated my library.dll.config to point to where the asmx is located too. – user644702 Mar 04 '11 at 12:52
  • Also, I have never been able to access their system as they have note xpposed it out of their network. Only developed it using a wsdl and an xml file that represents data being sent by their service – user644702 Mar 04 '11 at 12:53
  • Do you have the URI/URL they use in their test application? – Tony Abrams Mar 04 '11 at 12:54
  • Yeah I just realized the 'cannot access outside their network part' I removed that from my answer. – Tony Abrams Mar 04 '11 at 12:55
  • The url they have their service exposed in their test machine on their network is http://machinename/somewhere/clientservice/somemthing.asmx. When i RDP on their machine, i can open IE and hit that url – user644702 Mar 04 '11 at 13:03
  • This is going to be hard to answer without the full exception. – Tony Abrams Mar 04 '11 at 13:09
  • Will put it up in 1.5hrs as the clients are not in yet at work. – user644702 Mar 04 '11 at 13:11