0

EDIT: I cleaned a little up to make more clear, what's my problem. Sorry, it's less than it may look like. The whole xml is blowing up this post pretty much

I have a web service running on a remote server - a Linux device where some hardware is attached. This hardware, usually controlled by the linux server may also be connected over a web service by using wsdl. I got this project from a former employee and totally hung right now, because the web service won't work as I expect it.

As far as I understood the concept of webservices they deliver an interface which can be imported to a project to access the webservice as if it was a local library.

Hence I have added a new library to my solution, added a new service reference and downloaded the whole interface into my project (Project explorer->References->Add service reference). Now I have a DLL containing all the methods of webservice (service.dll) - so far, so good.

What I dont understand: This wizzard now created an app.config which - for my understanding is obsolete. The app.config contains:

  <configuration>
      <system.serviceModel>
          <bindings>
              <basicHttpBinding>
                  <binding name="ImageServerServiceSoapBinding" />
              </basicHttpBinding>
          </bindings>
          <client>
              <endpoint address="http://10.80.30.200:50000/xxxDataServer"
                  binding="basicHttpBinding" bindingConfiguration="ImageServerServiceSoapBinding"
                  contract="ServiceReference1.ImageServer" name="ImageServerPort" />
          </client>
      </system.serviceModel>
  </configuration>

Now I use this Service DLL in another project (driver.dll) where I implement access and unsage of the service encapsuled in a driver.

using MyService.ServiceReference1
// ...
public class MyClient
{
public void Connect() {
    this._Client = new ImageServerClient(
        _Settings.EndPointConfigurationName,
        @"http://" + _Settings.Physicals.IPAdress + ":" + 
        _Settings.Physicals.Port + _Settings.Physicals.SubDir);
}

The address built in the upper code points at: http://10.80.30.200:50000/xxxDataServer which is the same directory as the one used in the wsdl import wizzard.

The ImageServerClient is a part of the imported interface. It's definition is:

[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class ImageServerClient : System.ServiceModel.ClientBase<MySerivce.ServiceReference1.ImageServer>, MySerivce.ServiceReference1.ImageServer {

    public ImageServerClient(string endpointConfigurationName, string remoteAddress) : 
            base(endpointConfigurationName, remoteAddress) {
    }

For debugging purposes I have another Project (test.exe) in my solution referencing to the driver.dll.

In this test.exe I call the function

Client = new MyClient(MySettings);
Client.Connect();

So far so good. Calling the connect function in my driver.dll will call the service.dll to connect to the remote client.

This will work as long as the calling test.exe is holding the following information in the app.config:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="ImageServerServiceSoapBinding" messageEncoding="Mtom" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" algorithmSuite="Default"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://10.80.30.200:50000/xxxDataServer" binding="basicHttpBinding" bindingConfiguration="ImageServerServiceSoapBinding" contract="ServiceReference1.ImageServer" name="ImageServerPort"/>
    </client>
  </system.serviceModel>

The the then calling LabView is not compatible with the app.config scheme and therefore the driver.dll has to work autonomously without any additional config outside the driver.dll or the service.dll.

Removing the app.config data will end up in an error in the line:

this._Client = new ImageServerClient(Settings.EndPointConfigurationName,
                                     @"http://" + _Settings.Physicals.IPAdress + ":" + 
                                     _Settings.Physicals.Port + _Settings.Physicals.SubDir);

InvalidOperationException in System.ServiceModel.dll There was no endpoint element found with the Name "..." and the contract "..." in the ServiceModel-ClientConfiguration. This may have the folowing reasons: There was no configuration file found for this application or there was no EndPoint-Element found within the client element that matches the name. (Translated from german).

So what is wrong in my thoughts that this is not working? Why is it not enough, that all the basicHttpBinding stuff is already in the app.config from the service.dll (created by the wizzard)? Thank you :)

AllDayPiano
  • 414
  • 1
  • 4
  • 20

1 Answers1

1

As i understand, you want that the "driver.dll" will be the web service client.

if you're planning to use app.config, you're suppose to add it to your exe. but i understand you want to do everything programiclly.

so, your DLL should implement the connection, similar to this post (is your client a WCF client?):

How to programmatically connect a client to a WCF service?

or, if it's regular soap WS, you may want something similar to: http://forums.asp.net/t/1473676.aspx?SOAP+HttpWebRequest+POST+to+web+service

http://www.roelvanlisdonk.nl/?p=1893

app.config for your DLL will not work, as the app.config is hosted in the hosting application (EXE for example)

How to access app configuration from a .dll?

How to read app.config at dll level.?

Community
  • 1
  • 1
ArielB
  • 1,184
  • 2
  • 11
  • 36
  • Hi ArielB, thanks for you comment. Indeed I want the "driver.dll" be the main interface between the UI made in LabView and the WebInterface. I have no clue about the Remote Client but as far as I see, it implements a WSDL interface (I suppose its a linux client). The client however will not change. All given names and functions from the client will be the same. The web interface connect functions requires an IPEndPoint. That's however, why I don't understand why I need the app.config in any way... – AllDayPiano Nov 10 '15 at 06:11
  • You don't have to use app.config, but you probably connect with missing information, that's why you need the app.config. I suggest to do it programically. Can u share the app.config and connect code that fails? – ArielB Nov 10 '15 at 08:21
  • Well I'l try in another post to compress the source. – AllDayPiano Nov 10 '15 at 08:29
  • you can edit this post, not necessary to create a duplicate. – ArielB Nov 10 '15 at 08:34