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: Microsoft Windows 7 Basic
LVL 12
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

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
In a very simple Silverlight Application I have a DomainService Class which has a single method that returns a list of Letter Objects.

The application works fine when I run it in VisualStudio. However, when I publish it to a folder on my Windows 10 local machine and run it using IIS (version 10.0.166299.5) I get the following error:
The remote server returned an error: NotFound. at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Exception error) at System.ServiceModel.DomainServices.Client.LoadOperation.Complete(Exception error) at System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult) at System.ServiceModel.DomainServices.Client.DomainContext.<>c__DisplayClass1b.b__17(Object )

I supect this is due to something being wrong in missing in my WebConfig file. My WebConfig Currently looks like this:

<?xml version="1.0"?>

<configuration>


    <system.web>
      <compilation debug="true" targetFramework="4.6" />
      <httpRuntime targetFramework="4.6" />
    </system.web>




  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    </modules>
  

Open in new window

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 have 3 years of experience in Release Engineer and Software Engineer,

As I have less work for release management so I request for software development work to manager and got some work parallely. Now I am doing both Release as well as software development work in AngularJS, C#, WCF, MySQL, ASP.NET MVC etc. but my designation is "Release Engineer" . Now I want to switch to software engineer to different organization with this experience.

So is it possible? or how it should be done?

Please Help.

Thanks.
0
Is there any easy way to convert a WCF application to a pure web based application.
0
Hello guys,

I´m getting this error while trying to setup Outlook with autodiscover

Process w3wp.exe (FE_Autodiscover) (PID=8708). WCF request (Get Servers for sametime.cz) to the Microsoft Exchange Active Directory Topology service on server (TopologyClientTcpEndpoint (localhost)) failed. Make sure that the service is running. In addition, make sure that the network ports that are used by Microsoft Exchange Active Directory Topology service are not blocked by a firewall. The WCF call was retried 1 time(s). Error Details
 System.ServiceModel.Security.SecurityAccessDeniedException: Access is denied.

Server stack trace:
   at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter)
   at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at …
0
Hello,

I have a webservice that I,m trying to apply a custome security, when I try to call the service it display the following error:


http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">a:FailedAuthentication

At least one security token in the message could not be validated.


To add the security I modify the service config file:

[b][b]<services> <service name = "WcfService1.Service1"> <endpoint address="" binding="customBinding" bindingConfiguration="customBindingOasis" contract="WcfService1.IService1"> <headers> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken> <wsse:Username>USERNAME</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">PASSWORD</wsse:Password> </wsse:UsernameToken> </wsse:Security> </headers> </endpoint> </service> </services> <bindings> <customBinding> <binding name ="customBindingOasis"> <security authenticationMode="UserNameOverTransport" includeTimestamp="false" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"> <secureConversationBootstrap /> </security> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12" writeEncoding="utf-8"> <readerQuotas maxDepth="32"
0
Cloud Class® Course: C++ 11 Fundamentals
LVL 12
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Hello,

I have this WCF service that works fine using soap1. I'm trying to change it to run in soap1.2 but I have not been able.

I have try changin diferents things in the webconfig.

First I change the basicHttpBinding for wsHttpBinding.  I also change the protocol , remove the soap1.1 and add the soap 1.2

How I can made that my WCF web service run in soap1.2?
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
what are advantages of creating a REST service in Web API vs some other technologies in .NET like WCF, ASP .NET MVC etc.
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
Hello.

When trying to add a service reference I receive the following error:

"The configuration for the service reference could not be added due to the following issue: An error occurred creating the configuration section handler for system.serviceModel/bindings: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) (C:\....\web.config line 154)"

But, looking in web.config I am not seeing the problem.

Thanks. :)
0
Hello,
I have written a mock for a REST service using SoapUI free version. The resource path looks like <webservice>/employees which returns all employees in JSON. Now I want to pass a parameter which is a date range, something like <webservice>/employees?from=01-01-2017&to=31-12-2017
This will return only a few employees who joined during the date range. I am not able to find a way to accept parameters in the mock response and not sure how do i check something like if(date == 01-01-2017 to 01-04-2017) { //pass this json text   } else if(date == 08/08/2017 to 31/12/2017) { pass this text }

Any help would be greatly appreciated as I am new to SoapUI
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
>