Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

How to write Perl Client that uses WCF TCP/IP Service

by PerlApprentice (Initiate)
on Sep 02, 2011 at 21:58 UTC ( #923943=perlquestion: print w/replies, xml ) Need Help??
PerlApprentice has asked for the wisdom of the Perl Monks concerning the following question:

Well-respected Perl Monks, I'm seeking for your wisdom to help me find ways to use Perl under this scenario: I want to create a Perl Client that consumes data from a Windows Communication Foundation (WCF) Service using TCP/IP (NOT SOAP). The WCF Windows Service will be running on a Windows Machine and the Perl Client will run on client machines without .NET frameworks supporting WCF. I'd like to know if someone has done something similar using Perl. Any code samples or links or books to read from will be greatly appreciated. Here's a snapshot of my App.config file with the ABC data:
<services> <service behaviorConfiguration="MyDummyServiceBehavior" name="MyDummyService"> <endpoint address="net.tcp://localhost:8762/MyDummyService" bi +nding="netTcpBinding" bindingConfiguration="TCPBinding" name="TCPEndpoint" contrac +t="IMyDummyService"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="http://localhost:8732/MyDummyService/mex" b +inding="mexHttpBinding" name="Metadata" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8732/MyDummyService/" / +> </baseAddresses> <timeouts closeTimeout="23:59:59" openTimeout="23:59:59" /> </host> </service> </services>

Replies are listed 'Best First'.
Re: How to write Perl Client that uses WCF TCP/IP Service
by Marshall (Abbot) on Sep 02, 2011 at 22:43 UTC
    I think the statement of the problem is too general.
    I think you will have to get more specific in order to converge on a solution.

    Windows Communication Foundation (WCF) is a Microsoft technology. I doubt that it will be possible for a client on another machine that doesn't understand .NET to talk directly to this WCF service on the MS machine.

    It sounds like what you will need is a service, that you build, that runs on the MS machine that provides translation between Greek and hieroglyphics. Your client program talks to this translator service which then talks to the WCF server.

    Now, what this translation service does and how it works, I don't know. But it sounds like an translation layer between Microsoft and non-Microsoft is needed and that is a service that runs on the MS machine.

Re: How to write Perl Client that uses WCF TCP/IP Service
by Anonymous Monk on Sep 02, 2011 at 23:46 UTC

    (WCF) Service using TCP/IP (NOT SOAP)

    The wikipedia says WCF is as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues, etc so just use SOAP::Simple or SOAP::Lite or some such

      Thank you for your reply. I have been trying to get SOAP::Lite to work with my WCF Windows Service and all my efforts have been unsuccessful. Could you please tell me what I am doing wrong? My APP.CONFIG file in C#/XML looks like this:
      <?xml version="1.0" encoding="utf-8"?> <configuration> <connectionStrings> <add name="workorder_testEntities" connectionString="metadata=res: +//*/Database_Testing.csdl|res://*/Database_Testing.ssdl|res://*/Datab +ase_Testing.msl;provider=System.Data.SqlClient;provider connection st +ring=&quot;Data Source=MYSERVER-NAME,1433;Initial Catalog=MYDATABASE- +NAME;Persist Security Info=True;User ID=wo_dbo;Password=dbo2wo;Multip +leActiveResultSets=True&quot;" providerName="System.Data.EntityClient +" /> </connectionStrings> <appSettings> <add key="DB_conn" value="Data Source=MYSERVER-NAME,1433;Initial C +atalog=MYDATABASE-NAME;User ID=MYID;Password=MYPASSWORD;"/> </appSettings> <system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="Warning, Activit +yTracing" propagateActivity="true"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="De +fault"> <filter type="" /> </add> <add name="ServiceModelTraceListener"> <filter type="" /> </add> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="W +arning, ActivityTracing"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="De +fault"> <filter type="" /> </add> <add name="ServiceModelMessageLoggingListener"> <filter type="" /> </add> </listeners> </source> </sources> <sharedListeners> <add initializeData="c:\users\MYUSER\documents\tfs-code\app_trac +elog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Versi +on=, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp +"> <filter type="" /> </add> <add initializeData="c:\users\MYUSER\documents\tfs-code\app_mess +ages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Versi +on=, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions=" +Timestamp"> <filter type="" /> </add> </sharedListeners> <trace autoflush="true" /> </system.diagnostics> <system.serviceModel> <diagnostics wmiProviderEnabled="true"> <messageLogging logMalformedMessages="true" logMessagesAtTranspo +rtLevel="true" /> </diagnostics> <client> <endpoint address="http://MYSERVER-NAME:8732/Company.Department. +Project.WCFService.ProjectService/mex" binding="basicHttpBinding" bindingConfiguration="" contract="C +ompany.Department.Project.WCFService.IProjectService" name="Company.Department.Project.WCFService.ProjectService"> <identity> <certificateReference storeName="My" storeLocation="LocalMac +hine" x509FindType="FindBySubjectDistinguishedName" /> </identity> </endpoint> </client> <bindings> <basicHttpBinding> <binding name="NewBinding1" /> </basicHttpBinding> <netTcpBinding> <binding name="TCPBinding" closeTimeout="23:59:59" openTimeout +="23:59:59" receiveTimeout="23:59:59" sendTimeout="23:59:59" maxConnecti +ons="20"> <reliableSession inactivityTimeout="23:59:59" /> <security> </security> </binding> </netTcpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="Company.Department.Project.WCFService.ProjectS +erviceBehavior"> <serviceMetadata httpGetEnabled="True" /> <serviceDebug includeExceptionDetailInFaults="True" /> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="Company.Department.Project.WCFSe +rvice.ProjectServiceBehavior" name="Company.Department.Project.WCFService.ProjectService"> <endpoint address="net.tcp://MYSERVER-NAME:8762/ProjectService +" binding="netTcpBinding" bindingConfiguration="TCPBinding" na +me="TCPEndpoint" contract="Company.Department.Project.WCFService.IProjectServ +ice"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="http://MYSERVER-NAME:8732/Company.Departmen +t.Project.WCFService.ProjectService/mex" binding="basicHttpBinding" bindingConfiguration="" name="Com +pany.Department.Project.WCFService.ProjectService" bindingName="basicHttpBinding" contract="IMetadataExchange" +/> <host> <baseAddresses> <add baseAddress="http://MYSERVER-NAME:8732/Company.Depart +ment.Project.WCFService.ProjectService/" /> </baseAddresses> <timeouts closeTimeout="23:59:59" openTimeout="23:59:59" /> </host> </service> </services> </system.serviceModel> <system.web> <compilation debug="true" /> </system.web> </configuration>
      And my C# Interface looks like this:
      using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.Text; using Company.Department.Project.BusinessEntities; using Company.Department.ProjectB.BusinessLogic; using Company.Department.ProjectB.BusinessEntities; namespace Company.Department.Project.WCFService { [ServiceContract(Name = "Company.Department.Project.WCFService.Pro +jectService", Namespace = " +om/")] public interface IProjectService { [OperationContract(Name="GetWorkOrderList")] List<BEWorkOrder> GetWorkOrderList(string siteId); [OperationContract(Name="GetWorkOrder")] BEWorkOrder GetWorkOrder(string woName, string siteId); [OperationContract(Name="ReturnStatus")] string ReturnStatus(); } }
      And the PERL CODE I have looks like this:
      #!/usr/bin/perl -w use strict; use SOAP::Lite; my $url = 'http://MYSERVER-NAME:8732/Company.Department.Project.Projec +tService.ProjectService/?wsdl'; my $uri = ''; my $xmlns = ''; # Setup Network Connection my $soap = SOAP::Lite -> uri($uri) -> on_action(sub{sprintf '%sIProjectService/%s', @_}) -> proxy($url); my $response = $soap->GetWorkOrderList(SOAP::Data->new(name=>'siteId', + value=>'BKK')); if($response->fault){ die $response->faultstring; } else{ print $response->result; }
      The error that I get is "404 Not Found at line 17 which turns out to be "my $response = $soap->GetWorkOrderList(SOAP::Data->new(name=>'siteId', value=>'BKK'));" so it seems like the data is just not going through and being received in Perl. When I entered the URL in Chrome or IE (http://MYSERVER-NAME:8732/Company.Department.Project.ProjectService.ProjectService/?wsdl) I do get the XML page returned by the Server. What am I doing incorrectly for Perl not to be able to consume the WCF Service? Any ideas? Anyone who has successfully accomplished communication between WCF and Perl?
        Did you ever resolve this - I too am trying to get a console hosted WCF application to talk to a perl client. I can't believe it is not possible to either configure the service to be compatible with perl or to make the perl connect to the WCF service I have running. Surely it is all about interprocess and therefore cross platform communication?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://923943]
Approved by pileofrogs
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2019-02-21 13:26 GMT
Find Nodes?
    Voting Booth?
    I use postfix dereferencing ...

    Results (112 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!