WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
Go Back  Xtreme Visual Basic Talk > > > WCF ServiceContract shared in separate .dll


Reply
 
Thread Tools Display Modes
  #1  
Old 07-16-2010, 09:55 AM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default WCF ServiceContract shared in separate .dll


So I'm playing w/ WCF this week, it's pretty cool... I started with it to try to create a little GUI frontend to a service backend. Anyways I'm just playing with some more advanced things and ordered some books on it, but those are a few days away so I was hoping someone may be able to point me in the right direction for this.



Say I create an interface that acts as the ServiceContract... example:

Code:
Imports System.Runtime.Serialization

Namespace LoD.SomeNamespace

<ServiceConctract(Name:="ILoDServiceContract", Namespace:="LoD.Namespace")> _
Public Interface ILoDServiceContract
	
	<OperationContract()> Function Foo() As Boolean
	<OperationContract()> Sub Bar(ByVal value As String)
End Namespace

End Namespace
And I have this compiled into its own .dll along with a few other things. This dll is going to be known by both a service and a remote client that connects to the service. This means that when referencing the service there is no need for the wizard to create the interface when consuming the service into itself.

Basically how do I consume the WCF service manually instead of having the wizard do it and creating the servicecontracts interfaces and datacontracts that I already have defined?


essentially you know how when you add a new service reference and have the wizard take care of it, it generates a .vb file called 'References.vb' in the services folder... in it is implementations of several proxy classes and local 'DataContract' types that are shared between the service and the client... well most of them I don't need implemented (I already have them), I just need to manually write the proxies (the ones that inherit from System.ServiceModel.ClientBase).




For the moment all I do is have the 'ILoDServiceContract' client definition in it's own namespace 'MyServiceReference.ILoDServiceContract' and then I wrap the proxy type 'MyServiceReference.LoDServiceContractClient' in another facade 'SomeNamespace.LoDServiceContractClientTranslator' which implements the true interface 'LoD.SomeNamespace.ILoDServiceContract'. But that's just weird...
__________________
I'm a turtle... woooo

Last edited by lordofduct; 07-16-2010 at 10:13 AM.
Reply With Quote
  #2  
Old 07-16-2010, 01:35 PM
PlausiblyDamp's Avatar
PlausiblyDampWCF ServiceContract shared in separate .dll PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If you already have the interface available to the client (as you have) you could create an instance of the proxy through code and cast it's return to the interface. e.g. if the service was listening at http://example.com/test/sampleservice you could do something similar to
Code:
Dim ep as New new EndpointAddress("http://example.com/test/sampleservice")
Dim binding as new BasicHttpBinding()

Dim proxy as ILodServiceContract = ChannelFactory(Of ILodServiceContract).CreateChannel(binding, ep)
that the kind of thing you mean?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #3  
Old 07-16-2010, 06:00 PM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default

oh, ****, that's easy

thanks dude!


Everywhere I was looking was using the wizard to locate a service, and I figured that HAD to be a way to consume it manually... finding said info was proving annoying, but thankfully it's a pretty cake thing to do.
__________________
I'm a turtle... woooo
Reply With Quote
  #4  
Old 07-19-2010, 12:01 PM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default

so I had to create a BindingConfiguration for this that allowed for a much higher maxStringContentLength... but now that I have this I get this weird issue where it says it can't resolve the security:

Quote:
secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint.
This is the bindingConfiguration:

Code:
<bindings>
      <wsDualHttpBinding>
        <binding name="wsDuplexLargeData" transactionFlow="false" maxBufferPoolSize="104857600"
          maxReceivedMessageSize="104857600" messageEncoding="Text">
          <readerQuotas maxDepth="4096" maxStringContentLength="104857600"
            maxArrayLength="4096" maxBytesPerRead="104857600" maxNameTableCharCount="128" />
          <reliableSession ordered="false" />
        </binding>
      </wsDualHttpBinding>
      <wsHttpBinding>
        <binding name="wsLargeData" maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600">
          <readerQuotas maxDepth="4096" maxStringContentLength="104857600"
            maxArrayLength="4096" maxBytesPerRead="104857600" maxNameTableCharCount="128" />
          <security mode="Message">
            <message negotiateServiceCredential="true" algorithmSuite="Default"
              establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
</bindings>
1 is for duplex mode, the other for regular ws... both have the same exact error

I just have some large values put in to make sure I'm well above necessary (could this be part of the issue?)


yes I'm using WS... as seen here:

Code:
            Dim ep As New EndpointAddress(sUri)
            Dim binding As New WSDualHttpBinding()

            Return DuplexChannelFactory(Of IExDatabaseChannel).CreateChannel(callBack, binding, ep)
__________________
I'm a turtle... woooo

Last edited by lordofduct; 07-19-2010 at 12:15 PM.
Reply With Quote
  #5  
Old 07-20-2010, 03:06 AM
PlausiblyDamp's Avatar
PlausiblyDampWCF ServiceContract shared in separate .dll PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Are you getting these errors from the client or server side? Would it be possible to also see the services part of the config on the server side as well?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #6  
Old 07-20-2010, 08:20 AM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default

There error occurs on the client. There are actually two clients and they both act pretty much the same way.

WSDualHttpBinding - throws the security issue if I have the binding config, works fine without as long as string values are short (I'm pulling data from a database as xml so short strings are not an option).

WSHttpBinding - similar issues as WSDual

NetTcpBinding - the client->server connection goes into a faulted state as soon as I attempt to access any methods of the proxy.



Here is the client side for one of the client side apps (the one named in the config as ClientAccess), previous notes apply here:

Code:
<system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="ClientAccessTCP" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
                    transferMode="Buffered" transactionProtocol="OleTransactions"
                    hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                    maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
                    maxReceivedMessageSize="65536">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00"
                        enabled="false" />
                    <security mode="None">
                        <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
            </netTcpBinding>
            <wsDualHttpBinding>
                <binding name="ServerConfig" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="None">
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>
                </binding>
                <binding name="ClientAccessWS" closeTimeout="00:01:00" openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="128" maxStringContentLength="104857600"
                        maxArrayLength="16384" maxBytesPerRead="104857600" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="None">
                        <message clientCredentialType="Windows" negotiateServiceCredential="false"
                            algorithmSuite="Default" />
                    </security>
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:13001/exserver/serverConfig"
                binding="wsDualHttpBinding" bindingConfiguration="ServerConfig"
                contract="ExServerRef.IExServerConfigChannel" name="ServerConfig">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="http://localhost:13001/exserver/client"
                binding="wsDualHttpBinding" bindingConfiguration="ClientAccessWS"
                contract="ExServerRef.IExDatabaseChannel" name="ClientAccessWS">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint address="net.tcp://localhost:13000/exserver/client"
                binding="netTcpBinding" bindingConfiguration="ClientAccessTCP"
                contract="ExServerRef.IExDatabaseChannel" name="ClientAccessTCP" />
        </client>
    </system.serviceModel>

and the server side

Code:
<system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="netTcpLargeData" transactionFlow="false" maxBufferPoolSize="104857600"
          maxReceivedMessageSize="104857600">
          <readerQuotas maxDepth="4096" maxStringContentLength="104857600"
            maxArrayLength="4096" maxBytesPerRead="104857600" maxNameTableCharCount="128" />
          <reliableSession ordered="false" />
          <security mode="None" />
        </binding>
      </netTcpBinding>
      <wsDualHttpBinding>
        <binding name="wsDuplexLargeData" transactionFlow="false" maxBufferPoolSize="104857600"
          maxReceivedMessageSize="104857600" messageEncoding="Text">
          <readerQuotas maxDepth="4096" maxStringContentLength="104857600"
            maxArrayLength="4096" maxBytesPerRead="104857600" maxNameTableCharCount="128" />
          <reliableSession ordered="false" />
          <security mode="None">
            <message negotiateServiceCredential="false" />
          </security>
        </binding>
      </wsDualHttpBinding>
      <wsHttpBinding>
        <binding name="wsLargeData" maxBufferPoolSize="104857600" maxReceivedMessageSize="104857600">
          <readerQuotas maxDepth="4096" maxStringContentLength="104857600"
            maxArrayLength="4096" maxBytesPerRead="104857600" maxNameTableCharCount="128" />
          <security mode="Message">
            <message negotiateServiceCredential="true" algorithmSuite="Default"
              establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="ExServer.Service1Behavior"
        name="ExServer.ExServerEntry">
        <endpoint address="serverConfig" binding="wsDualHttpBinding"
          bindingConfiguration="wsDuplexLargeData" name="ServerConfig"
          contract="DMNet.Network.IExServerConfigChannel">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" name="MexAccess"
          contract="IMetadataExchange" />
        <endpoint address="client" binding="wsDualHttpBinding" bindingConfiguration="wsDuplexLargeData"
          name="ClientAccessWS" contract="DMNet.Network.IExDatabaseChannel" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="client" binding="netTcpBinding" bindingConfiguration="netTcpLargeData"
          name="ClientAccessTCP" contract="DMNet.Network.IExDatabaseChannel" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:13000/exserver/" />
            <add baseAddress="http://localhost:13001/exserver/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ExServer.Service1Behavior">
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
__________________
I'm a turtle... woooo

Last edited by lordofduct; 07-20-2010 at 08:29 AM.
Reply With Quote
  #7  
Old 07-21-2010, 10:50 AM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default

figured out my problem here, I'm just putting the configs in the wrong area...
__________________
I'm a turtle... woooo
Reply With Quote
  #8  
Old 07-21-2010, 01:43 PM
PlausiblyDamp's Avatar
PlausiblyDampWCF ServiceContract shared in separate .dll PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Glad you managed to sort it, I've been meaning to have a proper look at this for ages now (tab is still open from when you first posted it), every time I looked I remembered how confusing I find the WCF config sections.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #9  
Old 07-21-2010, 03:49 PM
lordofduct's Avatar
lordofduct lordofduct is offline
Centurion
 
Join Date: May 2010
Location: south florida yo
Posts: 120
Default

took a bit of just banging things together until something came out

anyways, my two books on WCF should be here tonight when I get home... gonna read up on it, because despite the learning curve for the configuration files, WCF seems really freakin' cool and I really enjoy the interface/proxy model approach they took with it. I was writing my own system when I came across it and it was like what I wanted to make... but with the 3 years of work it would have taken me already done.
__________________
I'm a turtle... woooo
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
 
WCF ServiceContract shared in separate .dll
WCF ServiceContract shared in separate .dll
 
-->