WCF

Windows Communication Foundation (WCF) is a tool used to implement and deploy a service-oriented architecture (SOA) to support distributed computing where services have remote consumers. It features a runtime and a set of APIs in the .NET Framework for building connected, service-oriented applications. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, regardless of which platform the service is hosted on. WCF implements many advanced Web services (WS) standards such as WS-Addressing, WS-ReliableMessaging, WS-Security, RSS Syndication Services, WS-Discovery, routing and better support for REST services.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi,

i'm newbie in C# and web service but i need to read the soap service (xml format) and save it to a SQL tables (dataset)...

here's my client's data:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:pix="">
      <soapenv:Header/>
      <soapenv:Body>
            <tem:Request>
                  <pix:wsVersion>v1.2.1</pix:wsVersion>
                  <pix:cname>Testaccount</pix:cname>
                  <pix:sclass>sales</pix:sclass>
                  <pix:PO>PO12345</pix:PO>
                  <pix:method>AIR</pix:method>
                  <pix:product>
                        <pix:style>Abc1</pix:style>
                        <pix:qty>1</pix:qty>
                        <pix:price>1.00</pix:price>
                  </pix:product>
                  <pix:product>
                        <pix:style>Cde1</pix:style>
                        <pix:qty>2</pix:qty>
                        <pix:price>1.00</pix:price>
                  </pix:product>
            </tem:Request>
      </soapenv:Body>
</soapenv:Envelope>

I have 2 classes:
class order
            [MessageBodyMember(Order = 0)]
            public string wsVersion { get; set; }
            [MessageBodyMember(Order = 1)]
            public string cname { get; set; }
            [MessageBodyMember(Order = 2)]
            public string PO { get; set; }
            [MessageBodyMember(Order = 3)]
            public string method { get; set; }
            [MessageBodyMember(Order = 4)]
            [XmlArrayItem("oItems", IsNullable = false)]
            public Item[] Items { get; set; }
class Item
            [XmlElement(Order = 0)]
            public string style { get; set; }
            [XmlElement(Order = 1)]
            public int qty { get; set; }
            [XmlElement(Order = 2)]
            public double price { get; set; }

in service.svc.cs

0
Cloud Class® Course: CompTIA Cloud+
LVL 12
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

When I run my  WCF api I get the below code from WCF Test Client tool and my Test WebSite.  What do I need to do in my MVC VS 2015 webconfig file on the server and the client to get this apito work?

The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'NTLM,Negotiate'.
I have IIS7.
0
Aside from removing the TransactionScope created on the WCF client (and effectively taking msdtc out of the picture), Is there an alternate way to avoid the excessively long WCF-service-wide hang when a single workstation hosting the WCF client is misconfigured (or experiencing communications issues)?

We have a simple WCF service implemented using C#, and a simple WCF Client which creates TransactionScope before invoking the WCF service proxy.

Both work fine as far as concurrency goes if Windows Firewall allows TCP communication from/to msdtc.exe thru firewall. However if a single workstation is misconfigured (i.e. has firewall enabled, and has an Inbound Rule for TCP for msdtc.exe disabled), its attempt to communicate with the service will block all other WCF clients (which are properly configured) from communicating with the WCF Service for at least 41 seconds (given the currect settings for TCP retransmissions), despite us using much shorter timeout settings for the WCF binding as well as for the TransactionScope timeout.    

 The WCF service is decorated with
    [System.ServiceModel.ServiceBehavior(
        InstanceContextMode = System.ServiceModel.InstanceContextMode.PerCall,
        ReleaseServiceInstanceOnTransactionComplete = false,
        ConcurrencyMode = System.ServiceModel.ConcurrencyMode.Multiple,
        IncludeExceptionDetailInFaults = false,
        TransactionTimeout = "00:00:13"
       )
The WCF service has a single operation contract, …
0
I have the codes below
1. RetrieveData is working fine., but now I want to assign class library value in a loop.
Basically, I have wcf call to get the list of name which is exactly same as class library property name - see newretrievedata
Is it possible to do that?

On another side of class library in c#, i already have all of the property/object in class library.


     
  public JsonResult RetrieveData(string ID)
        {
            Domain.Lead l = new Domain.Lead();
            l.firstname = "John";
            l.lastname = "Smith";
            return Json(l, JsonRequestBehavior.AllowGet);
        }

 
        public JsonResult newRetrieveData(string ID)
        {
            Domain.Lead l = new Domain.Lead();


            foreach (KeyValuePair<string, string> i in Helper.DynamicsCRM.GetAllLeadInfoByMetaData3("a51ec467-7255-e811-81153863bb3c4538"))
            {               
                //Response.Write(i.Key + " >> " + i.Value + "<br>"); Key has firstname, and lastname, etc.
            	l.i.Key = i.Value;
            }
            return Json(l, JsonRequestBehavior.AllowGet);
        }

Open in new window

0
I am trying to Integrate Swagger with a WCF service by following the article SwaggerWCF

I skipped ASP.Net part as i dont have ASP.Net in my project

The steps are not clearly stating whether these changes have to made in the service or in the host, mine is a self hosted service.

I have tried making changes in both the places (service and host, i am always getting
failed to parse JSON/YAML response swaggerwcf

Please help if i am missing anything

Adding project code

Service Project (WCFSample)

Service Interface

public interface IService1
{
[SwaggerWcfPath("Get Data", "Gets Data")]
[WebInvoke(UriTemplate = "/data",
BodyStyle = WebMessageBodyStyle.Bare,
Method = "Get",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
string GetData(int value);

    [SwaggerWcfPath("Get Data", "Gets Data using data contract")]
    [WebInvoke(UriTemplate = "/datawithcontract",
        BodyStyle = WebMessageBodyStyle.Bare,
        Method = "Get",
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json)]
    [OperationContract]
    CompositeType GetDataUsingDataContract(CompositeType composite);

    // TODO: Add your service operations here
}

// Use a data contract as illustrated in the sample below to add composite types to service operations.
// You can add XSD files into the project. After building the project, you

Open in new window

0
I am using WCF callback services for Real-Time User availability and text/video chat application and i have included reliable session with a receive timeout of 10 mins.The problem i face is when a message has to be broadcast for all users(say 10 users) i am using a for loop and if a client has disconnected from internet on his side the loop waits for 10 mins to reach the same client without broadcasting the message to other clients.
 Is there any alternative or a better approach for accessing other clients in the meantime or any work around.
0
Hey all I am using the following code on my local machine to give me a temporary WCF service:
    using System;
    using System.Windows.Forms;
    using System.ServiceModel;
    using TestService;
    
    namespace TestClient
    {
        public partial class Form1 : Form
        {
            IService1 patientSvc = null;
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                EndpointAddress address = new EndpointAddress(new Uri("net.tcp://localhost:2202/PatientService"));
                NetTcpBinding binding = new NetTcpBinding();
                ChannelFactory<IService1> factory = new ChannelFactory<IService1>(binding, address);
                patientSvc = factory.CreateChannel();
            }
        }
    }

Open in new window

And the class1:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.ServiceModel;
    using System.Runtime.Serialization;
    
    namespace TestService
    {
        [ServiceContract()]
        public interface IService1
        {
            [OperationContract]
            Patient GetPatient(Int32 index);
    
            [OperationContract]
            void SetPatient(Int32 index, Patient patient);
        }
    
        [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
        public class PatientService : IService1
        {
            Patient[]

Open in new window

0
I'm getting the following error:
The incoming message was signed with a token which was different from what used to encrypt the body.  This was not expected.

I'm thinking it has to do something with my app.config file
<system.serviceModel>
    
    <diagnostics>
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="false"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="false"
           maxMessagesToLog="3000"
           maxSizeOfMessageToLog="2000"/>
    </diagnostics>
    <client>
      <endpoint address="https://xxxxxx/ESARWS/CORETransactionService"
        behaviorConfiguration="endpointCredentialBehavior" binding="customBinding"
        bindingConfiguration="esar" contract="ESAR.CORETransaction"
        name="CoreSoapPort">
        <identity>
          <dns value="xxxxx" />
        </identity>
      </endpoint>
    </client>
   <behaviors>
     <endpointBehaviors>  
        <behavior name="endpointCredentialBehavior">
         
          <clientCredentials>  
            <clientCertificate findValue="xxxxx"
                               storeLocation="CurrentUser"
                               storeName="My"
                               x509FindType="FindBySubjectName"/>
            
           <serviceCertificate>
             <authentication certificateValidationMode="ChainTrust"/>
              <defaultCertificate findValue="xxxxxxxxx"
                               

Open in new window

0
I'm using C# to call a Java Webservice.  Fiddler gives me a status of 200. So my call to the service is good.  But something in the .NET does not like my MTOM message.  Any ideas?  Here are all the details.  

I'm getting this error:
MTOM messages must have type 'application/xop+xml'.

Open in new window


The stack trace says:
Server stack trace: 
   at System.ServiceModel.Channels.MtomMessageEncoder.MtomBufferedMessageData.TakeXmlReader()
   at System.ServiceModel.Channels.BufferedMessageData.GetMessageReader()
   at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
   at System.ServiceModel.Channels.MtomMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
   at System.ServiceModel.Channels.HttpInput.DecodeBufferedMessage(ArraySegment`1 buffer, Stream inputStream)
   at System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
   at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(HttpRequestMessage httpRequestMessage, Exception& requestException)
   at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at 

Open in new window

0
I'm trying to call a Java web service with an attachment in C#.    

string soap = "<?xml version='1.0' encoding='utf-8'?> <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:soap='http://www.w3.org/2003/05/soap-envelope' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:int='http://xxxxx.com/'>" +
               "<soap:Header/> " +
                "<soap:Body> " +
                "	<int:xxxxxSubmission> " +
                "	xxxxxxxxxxxx " +
                "	</int:xxxxxSubmission> " +
                "</soap:Body> " +
                "</soap:Envelope> ";

            X509Certificate2 cert = new X509Certificate2(@"C:\Test\xxxxxx.pfx", @"xxxxx");
            X509Certificate2 cert2 = new X509Certificate2(@"C:\Test\xxx.cer", @"xxxxx");

            HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://xxxxx/TestService");

            req.ContentType = "application/soap+xml;charset=\"utf-8\"";
            req.Accept = "application/soap+xml";
            req.Method = "POST";
            req.Host = "test";
            req.KeepAlive = true;
            req.ClientCertificates.Add(cert);
            req.ClientCertificates.Add(cert2);


            using (Stream stm = req.GetRequestStream())
            {
                using (StreamWriter stmw = new StreamWriter(stm))
                {
                    stmw.Write(soap);
                    stmw.Close();
                }
            }

            WebResponse response = 

Open in new window

0
Cloud Class® Course: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

I'm calling a web service where I'm suppose to encrypt the data being passed over.    When I look at the diagnostic file I don't see my payload being encrypted.  Am I missing something in the app.config file for the encryption to occur?

Here is my app.config file:
<system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging">
        <listeners>
          <add name="messages"
          type="System.Diagnostics.XmlWriterTraceListener"
          initializeData="c:\logs\messages.xml" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>


  <system.serviceModel>
    <diagnostics>
      <messageLogging
           logEntireMessage="true"
           logMalformedMessages="false"
           logMessagesAtServiceLevel="true"
           logMessagesAtTransportLevel="false"
           maxMessagesToLog="3000"
           maxSizeOfMessageToLog="2000"/>
    </diagnostics>
    <bindings>
        <wsHttpBinding>
          <binding name="CoreSoapPortBinding">
            <security mode="Transport">  
              <transport clientCredentialType="Certificate"/>  
            </security>  
          </binding>  
        </wsHttpBinding>  
    </bindings>
    <client>
        <endpoint address="https://xxxxxxxxx/ESARWS/CORETransactionService"
            binding="wsHttpBinding" bindingConfiguration="CoreSoapPortBinding"
            contract="ESAR.CORETransaction" name="CoreSoapPort" behaviorConfiguration="endpointCredentialBehavior" 

Open in new window

0
Error method not allowed usin g POST in WCF


i want to send data from android to sqlserver using wcf post method because i want to send a stream of basex64 as a image in a parameter which GET method not accept in a browser but the post method can do this work.Kindly tell me the use of post method in WCF.Is is requires any additional information in post method?My all GET methods working fine.
First time post the problem hope so any one can rep me,tnx bilawal sharif
0
Client javascript calls aspx.vb. VB code behind which then calls a WCF data contract that returns data from an SQL data base. That data is then serialized and inserted into a response.write() method.

 It fails. No exceptions, no errors, nothing.

 After the WCF HTTPS call, the response.isClientConnected property is getting set to 'false'. Making the HTTPS call to the WCF service is making the response.write lose it's connection to the client that called it.

 Any ideas to get around this?

What I have tried:

1 -  I have taken the data returned from the WCF call, and pasted it as a string in the response.write("").

      If I then comment out the WCF HTTPS call, it works fine.

2 - I've tried moving the function that calls the WCF out of the aspx.vb that has the response.write.  No change.
0
UWd5sNhn
I cant upload or run moving wallpaper on this iphone 6s plus
Whats mean is the Mobifone Witalk network? In Vietnam im used VN mobifone. But while im work in to Apple the network change to Mobifone Witalk. Please help me to explain. Thanks
Safari---05-02-30-Heisei-09-33.pdf
FCC5930F-000B-44ED-8C95-539E7B5A7CA2.MOV
F1A7106D-423F-440A-9DD6-06C23D26D34F.png
0
Hi,

I hope that someone is able to help. The web development team have changed the current website that we are using. We have an order download application that integrated into mageno.

The issue is that I try to change the endpoint address to the following and I receive an error:

https://old.filofax.co.uk/index.php/api/v2_soap/index/?wsdl=1

Error message is attached(error1)

I have also tried to generate a proxy class using the same error message.

My issue is that I can browse to this URL ok.

I would appreciate any help. I have contacted the hosting company and they don't have any iea.

Best Regards,

Ross
error1.png
0
Hi, I am looking for some guidance in relation to WPF & WCF!

I currently have a  niche Point of Sale application that is written using Winforms and communicates to a ASP.NET web service. Whilst this currently works well. I am starting to reach the limits with the Winforms.  I am starting to plan the next major release of the software and I am thinking now is the best time to re-develop using more modern technology.

I am a self taught developer and whilst I have managed to produce a very stable application, I know I could have done things very different.

What I am hoping for is for some guidance on what i should and shouldn't do  this time around in the new WPF & WCF project.
If anyone is interested, my product can be found at pawnit365.com.au

The current application makes use of Tabs, and I want to continue to do this as its very popular. Users like it. However at the moment tabs are only limited to 1 instance of a tab type. Id like to allow users to have multiples of the same tab open at once.

Any help anyone is willing to offer or provide would be greatly appreciated.
0
Hi there,
We have a customer who is using a software provider who's product is hosted in the cloud. Basically the customer has a reporting tool that they would like to connect to the back end of the software to interrogate and pull data out. The software provider wont allow this, but they are going to setup a WCF service which pulls the data out of their SQL server, and makes it available to the customer. What we need to do is create a WCF client that can connect to the WCF service, and pull the data out (ie daily), and then we would like to store the data in a local SQL DB, where the reporting tool can interrogate. Any thoughts / tips on this?
0
I have a self-hosted VBNet database application that utilizes WCF.  It communicates with another WCF application.  When the first application is running in the debugger on a Windows 10 machine, it refuses to allow connections.  Running in the debugger on a Windows 7 machine does not cause this problem nor is the problem present in release mode regardless of the OS.  Any suggestions to solve this problem would be appreciated.
0
I currently have a C# WCF Service hosted in IIS 8.5  which allows users to print labels. Because the label printers are local printers for each user (USB connection on their laptops) they are forced to open the label in their browser and then click print on each label to print to local label printer. What the users want is for the labels to print automatically without any user intervention but without the printers being networked this does not seem possible - or is it?

Is it possible to use FTP to drop the text files (labels) directly onto the label printer spool queue of the laptop requesting the label?  The Service will have the IP address of each logged in user  but how can I send a file to a spooler rather than a folder and if it can be done can it be done silently ,without any user interaction.

I notice that when I send a label manually to the USB printer on the laptop (Windows 7 64bit) there are two files populated into c:/windows/system32/spool/PRINTERS. a SHD file type and a SPL file type. Is there any way of generating these two file for  the label text file to be printed?
 
I assume that a common FTP Site would need to be configured on each laptop for this to work. Appreciate any guidance and/or examples I can get.

regards
Pat
0
Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Hi Experts,

Quick question. Just followed this article here
http://bitoftech.net/2014/10/27/json-web-token-asp-net-web-api-2-jwt-owin-authorization-server/

I have tested with Postman but it doesn't really say how you can run the project on visual studio

any ideas as always will be helpful..

Thanks

Mike
0
I dont want to re-invent the wheel and build a new WCF or Rest webservice. Please advise, how can I find out if the service I need has already been created by someone? I would love to be able to re-use that WCF/Rest service.

Example: I need a service that would convert currencies.

Thanks,
Ricky
0
All

We have a requirement where we need to build a WCF service which can make outbound calls (as client) to backend services which requires 2-way SSL (mutual-authentication).

We have been trying this with no luck. It works with 1-way SSL (WCF as client), but when we set the backend services to require 2-way SSL, the handshake failed at the point where WCF is supposed to send its certificate to the backend service, but it doesn't.

Any one has experience doing this? Any clues of what the problem could be will be much appreciated.

Best Regards
Charles
0
public void PostImagesToServer(Stream Images)
        {
         
            try
            {
                Guid Unique = System.Guid.NewGuid();
                string U = Unique.ToString();
                string Name = U + ".jpg";
                FtpWebRequest req = (FtpWebRequest)WebRequest.Create("ftp://NikhelPrans117@182.50.151.43/webservice/ChachaChaudaryImages/ComicImages/" + Name);
                req.Credentials = new NetworkCredential("NikhelPrans117", "Nilesh@2188");
                req.KeepAlive = true;
                req.UseBinary = true;
                req.Method = WebRequestMethods.Ftp.UploadFile;
                byte[] fileData = StreamToByte(Images);
                req.ContentLength = fileData.Length;
                Stream reqStream = req.GetRequestStream();
               
                reqStream.Write(fileData, 0, fileData.Length);
               
                reqStream.Close();
}
0
Trying to consume webservice using wcf client, getting following error

The content type multipart/related; boundary=MIMEBoundaryurn_uuid_B50EC784A204DC07C91495512014914; type="text/xml"; start="<0.urn:uuid:B50EC784A204DC07C91495512014915@apache.org>"; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the  . The first 1024 bytes of the response were ...

Fiddler is showing the complete response but wcf is not able to deserialize the complete response. Response contains Japanese characters.
0
This app.config is resided in my c# class library. and I have class library called service.cs


I also have web application in c# and try to called service.cs (of course I added reference inside of the web app)
and I have alert about "Could not find default endpoint element that references contract"

so I create another web application project and add web reference directly and the webconfig is exactly the same. there is no error and I can call as usual.
What did I do wrong?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
              <binding name="BasicHttpBinding_IQuotingService" allowCookies="true" maxBufferSize="20000000" maxReceivedMessageSize="20000000">
                <readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"/>
                <security mode="Transport"/>
              </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="abc.svc" 
                      binding="basicHttpBinding" 
                      bindingConfiguration="BasicHttpBinding_IQuotingService" 
                      contract="NGICService.IQuotingService" 
                      name="BasicHttpBinding_IQuotingService"
                      />
        </client>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1"/></startup></configuration>

Open in new window

0

WCF

Windows Communication Foundation (WCF) is a tool used to implement and deploy a service-oriented architecture (SOA) to support distributed computing where services have remote consumers. It features a runtime and a set of APIs in the .NET Framework for building connected, service-oriented applications. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, regardless of which platform the service is hosted on. WCF implements many advanced Web services (WS) standards such as WS-Addressing, WS-ReliableMessaging, WS-Security, RSS Syndication Services, WS-Discovery, routing and better support for REST services.

Top Experts In
WCF
<
Monthly
>