I am working on integrating the A2A channel for the IRS through their WSDL and currently stuck on an issue in my App.config. Currently there is a warning for the <gzipMessageEncoding/> node of my App.config:
The element 'binding' has invalid child element 'gzipMessageEncoding'. List of possible elements expected: (...).
I've looked over solutions provided by fatherOfWine, Russ, and jstill primarily here and I've gotten stuck now on this config hiccup. From what I've researched people seem to say you can just ignore this as a warning and continue but attempting to send to the IRS leads to the following error.
Invalid element in configuration. The extension 'gzipMessageEncoding' does not derive from correct extension base type 'System.ServiceModel.Configuration.BindingElementExtensionElement'.
Below is the snippet of my service model config. I have the encoder in a different place than fatherOfWine had suggested but I believe I have the correct types setup.
<system.serviceModel>
<client>
<endpoint address="[Endpoint Address]"
binding="customBinding" bindingConfiguration="BulkRequestTransmitterBinding"
contract="ACABulkRequestTransmitterService.BulkRequestTransmitterPortType"
name="BulkRequestTransmitterPort" />
<metadata>
<policyImporters>
<extension type="GZipEncoder.GZipMessageEncodingBindingElementImporter, GZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</policyImporters>
</metadata>
</client>
<extensions>
<bindingElementExtensions>
<add name="gzipMessageEncoding" type="GZipEncoder.GZipMessageEncodingElement, GZipEncoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
<bindings>
<customBinding>
<binding name="BulkRequestTransmitterBinding">
<gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
UPDATE 1: Changing the second variable in the type field to GZipMessageEncoder throws a new exception at the same place.
'The type 'Utilities.Gzip.GZipMessageEncodingBindingElement, GZipMessageEncoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null' registered for extension 'gzipMessageEncoding' could not be loaded.'
Still going to try and move the gzip code into its own project like shown in the link above.
UPDATE 2: Moving the Gzip library into its own project seems to have helped resolve the exception thrown during runtime. I've gone ahead and updated my App.config file above with what has changed. I'm now at the same point/issue in both my current working methods! lol but it's probably best in a different question if it comes to that.
That is the same warning I am receiving when I review my App.config. It seems like you can ignore the warning; which indicates that there is a different issue with the way your code is setup.
Below is a snippet of my App.config having the appropriate elements:
<system.serviceModel>
<customBinding>
<binding name="BulkRequestTransmitterBinding" sendTimeout="00:15:00">
<gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />
<httpsTransport />
</binding>
<client>
<!-- Endpoints are setup by the import of the IRS Service so I will not include them here -->
<endpoint for transmission />
<endpoint for status />
<metadata>
<policyImporters>
<extension type="[ProjectName].GZipMessageEncodingBindingElementImporter, GZipMessageEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</policyImporters>
</metadata>
</client>
<extensions>
<bindingElementExtensions>
<add name="gzipMessageEncoding" type="[ProjectName].GZipMessageEncodingElement, GZipMessageEncoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
</customBinding>
</system.serviceModel>
Related
How do I run a SSRS report using VS2015 in a SSIS package. The following answer is not the latest way of doing this apparently from what I have read. This post is the old way
how to run SSRS reports using SSIS? because it mentions ReportExecutionService not ReportExecutionServiceSoapClient.
I also tried another sites answer when I call the proxy (like first line of code it fails.
var webServiceProxy = new ReportExecutionServiceSoapClient("ReportExecutionServiceSoap")
Error I get is:
An exception of type 'System.InvalidOperationException' occurred in System.ServiceModel.dll but was not handled in user code
Additional information: Could not find endpoint element with name 'ReportExecutionServiceSoap' and contract 'ServiceReference1.ReportExecutionServiceSoap' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
It does not matter if I use the default config or the one from the below example or if I call the constructor that does not require a endpoint, so I am lost what else to try.
Refer to:
C# Example in SSIS
app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services />
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig" allowCookies="true" maxReceivedMessageSize="5242880">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://<myserver>/reportserver/ReportExecution2005.asmx?WSDL"
binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfig"
contract="ServiceReference1.ReportExecutionServiceSoap" name="ReportExecutionServiceSoap" />
</client>
</system.serviceModel>
</configuration>
Also at design time there is a warning:
The 'contract' attribute is invalid - The value 'ServiceReference1.ReportExecutionServiceSoap' is invalid according to its datatype 'clientContractType' - The Enumeration constraint failed.
I have several web services that I am connecting to from a Visual Studio C# project using service references. Two of the service references were created and work without a problem, and one of them took quite a lot of effort to get imported, and now seems to not be working.
I believe the problem lies in the app.config file since it is getting a "Could not find endpoint element" error when I try to create the client.
Here is the app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="RateQuoteSoap">
<security mode="Transport" />
</binding>
<binding name="RateQuoteSoap1" />
<binding name="QuoteSoap" />
<binding name="WebservicePrimusSoapBinding" />
</basicHttpBinding>
<customBinding>
<binding name="QuoteSoap12">
<textMessageEncoding messageVersion="Soap12" />
<httpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint
address="https://webservices.rrts.com/rating/ratequote.asmx"
binding="basicHttpBinding"
bindingConfiguration="RateQuoteSoap"
contract="RoadRunnerService.RateQuoteSoap"
name="RateQuoteSoap" />
<endpoint
address="http://services.echo.com/Quote.asmx"
binding="basicHttpBinding"
bindingConfiguration="QuoteSoap"
contract="EchoService.QuoteSoap"
name="QuoteSoap" />
<endpoint
address="http://services.echo.com/Quote.asmx"
binding="customBinding"
bindingConfiguration="QuoteSoap12"
contract="EchoService.QuoteSoap"
name="QuoteSoap12" />
<endpoint
address="http://api.shipprimus.com/"
binding="basicHttpBinding"
bindingConfiguration="WebservicePrimusSoapBinding"
contract="PrimusService.WebservicePrimusServicePort"
name="WebservicePrimusServicePort" />
</client>
</system.serviceModel>
</configuration>
The PrimusService is the one that is not working correctly, and the full error when I try to initialize the client like WebservicePrimusServicePortClient serviceClient = new WebservicePrimusServicePortClient("WebservicePrimusServicePort"); is
System.InvalidOperationException: Could not find endpoint element with name 'WebservicePrimusServicePort' and contract 'PrimusService.WebservicePrimusServicePort'in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
I have also tried to simply initialize a BasicHttpBinding object using the binding name and the endpoint name with no luck (short variable names for readability)
BasicHttpBinding a = new BasicHttpBinding("QuoteSoap"); // Works fine
BasicHttpBinding b = new BasicHttpBinding("WebservicePrimusSoapBinding"); // Fails
BasicHttpBinding c = new BasicHttpBinding("WebservicePrimusServicePort"); // Fails
It throws no error for binding a, but binding b and c fail with the error:
System.Collections.Generic.KeyNotFoundException: No elements matching the key 'WebservicePrimusSoapBinding' were found in the configuration element collection.
While not a direct solution, I ended up just taking the information from the app.config and creating my own BasicHttpBinding and EndpointAddress objects in code. This is more of a workaround than a fix for the problem, and I still don't know why I couldn't access the information in the app.config directly.
I followed the solution in this answer about how to consume a service without using the app.config file.
I created my BasicHttpBinding like
BasicHttpBinding binding = new BasicHttpBinding();
binding.Name = "PrimusServiceBinding"; // Completely Unnecessary
and my endpoint like
EndpointAddress endpoint = new EndpointAddress("http://api.shipprimus.com/");
and could connect to the service and retrieve information without a problem, even providing as little information as I did (basically just the address).
My app.config is as follows:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ESDServiceSoapBinding">
<security mode="Transport" />
</binding>
<binding name="ESDServiceSoapBinding1">
<security mode="Transport" />
</binding>
<binding name="ESDServiceSoapBinding2" />
<binding name="ESDServiceSoapBinding3" />
<binding name="ESDServiceSoapBinding4">
<security mode="Transport" />
</binding>
<binding name="ESDServiceSoapBinding5" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://downloadswebregr.mydomain.com:443/ESDServiceWeb/services/ESDEntitlementServiceAPI"
binding="basicHttpBinding" bindingConfiguration="ESDServiceSoapBinding1"
contract="ESDRegService.ESDEntitlementServiceAPI" name="ESDEntitlementServiceAPI" />
<endpoint address="http://eotwasqa1.mydomain.com:19081/ESDServiceWeb/services/ESDEntitlementServiceAPI"
binding="basicHttpBinding" bindingConfiguration="ESDServiceSoapBinding3"
contract="ESDBackupService.ESDEntitlementServiceAPI" name="ESDEntitlementServiceAPI1" />
<endpoint address="https://downloadsweb.mydomain.com:443/ESDServiceWeb/services/ESDEntitlementServiceAPI"
binding="basicHttpBinding" bindingConfiguration="ESDServiceSoapBinding4"
contract="ESDBackupService.ESDEntitlementServiceAPI" name="ESDEntitlementServiceAPI2" />
</client>
</system.serviceModel>
</configuration>
I tried embedding this inside the executable using the build action "Embedded Resource" but then my application is not able to read the services information. I want to get rid of it as I want to ship only a single file. i.e. the executable.
I searched for similar questions on stackoverflow and people say, it should be outside so that it can be configured or modified from outside.
Please note that, I dont want it to get changed from outside and just want to embed it.
The basic purpose of the configuration file is to allow the external users to configure something in your application.Hence the configuration files needs to be distributed to the end users.If you intend not to allow changes to the end points ,it has to created inside your code as suggested in the previous comment.
Check the following link.
Create WCF endpoint configurations in the client app, in code?
I know that this question has been asked to death, yet the answer remains elusive. I've been through numerous posts with suggested solutions but this error continues to plague me. Any help would be greatly appreciated.
I have a .Net 4.5 WCF service hosted on IIS which is consumed by an MVC5 web site on another IIS box. Communication works fine for the most part, but I need to allow the web site to upload files to the WCF service and the calls are all bombing out with the following error:
An unexpected error occurred: The remote server returned an unexpected response: (413) Request Entity Too Large
The methods being called in the web service take a single POCO as a parameter. The POCO contains a number of properties including a byte array for the contents of the file being uploaded. For example:
public class ProofOfAddressRequest : RequestBase
{
public string AddressLine1 { get; set; }
public string AddressLine2 { get; set; }
public string Region { get; set; }
public string City { get; set; }
public string PostCode { get; set; }
public string Country { get; set; }
public string FileName { get; set; }
public byte[] FileBytes { get; set; }
}
public ProofOfAddressResponse SubmitProofOfAddress(ProofOfAddressRequest data)
{
// TODO... Save the record
}
The web site's web.config is currently as follows:
<configuration>
<configSections/>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IUserService" maxBufferPoolSize="2097152" maxBufferSize="2097152" maxReceivedMessageSize="2097152">
<readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:58354/Services/UserService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserService"
contract="UserService.IUserService" name="BasicHttpBinding_IUserService" />
</client>
</system.serviceModel>
<system.web>
<customErrors mode="Off" />
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="4096"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
And the web service's web.config is:
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="4096"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding" maxBufferPoolSize="2097152" maxBufferSize="2097152" maxReceivedMessageSize="2097152">
<readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceWithMetadata">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpBinding" scheme="http" />
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true" />
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
What I would like is to understand HOW to configure my config file(s) to allow a maximum upload size of say 2MB. If it is possible to pass the data in binary format rather than Base64 (or whatever) that would also be advantageous to decrease the bandwidth requirements between servers.
Communication between sites is currently over HTTP in my dev environment, but I'll also need to configure for HTTPS for test/production. Bonus points for pointers on the additional config.
Thanks in advance for any help you can provide on this. It's cost me a fair amount of time already and I'm no closer to a solution.
Found my answer - I originally posted a link to it here, but one of the mods decided to delete the answer (thanks for that!), so I'll post the solution in its entirety instead:
In order to allow payloads (such as files or large arrays of data) OVER the default of 40KB to be sent to a WCF Service method, the changes required are predominantly in the web.config file of the WCF project. There is also one minor tweak required in the client's configuration, so we'll look at that first:
<configuration>
...
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- Large Message Upload (Begin) -->
<binding name="BasicHttpBinding_IUserService" maxBufferPoolSize="2097152" maxReceivedMessageSize="2097152" />
<!-- Large Message Upload (End) -->
<binding name="BasicHttpBinding_ISystemService" />
...
</basicHttpBinding>
</bindings>
...
</system.serviceModel>
</configuration>
When you first add a service reference to your client's project, Visual Studio automatically creates default binding and endpoint nodes in your config file. You'll need to add two new attributes to the binding node for your service: maxBufferPoolSize and maxReceivedMessageSize. Both attributes should have their values set to your desired file upload size limit IN BYTES. You'll also need to take note of the name for the next bit.
That's if for the client configuration, so on to the WCF Service. Here's an extract from mine:
<configuration>
...
<system.serviceModel>
<bindings>
<basicHttpBinding>
<!-- Large Message Upload (Begin) -->
<binding name="BasicHttpBinding_IUserService"
maxBufferSize="2097152"
maxBufferPoolSize="2097152"
maxReceivedMessageSize="2097152"
closeTimeout="00:50:00"
openTimeout="00:50:00"
sendTimeout="00:50:00"
receiveTimeout="00:50:00">
<readerQuotas maxDepth="32" maxStringContentLength="100000"
maxArrayLength="2097152" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None" />
</binding>
<!-- Large Message Upload (End) -->
</basicHttpBinding>
</bindings>
<services>
<!-- Large Message Upload (Begin) -->
<service name="BlexEngine.Services.UserService"
behaviorConfiguration="ServiceWithMetadata">
<endpoint name="Default"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IUserService"
contract="BlexEngine.Services.IUserService" />
</service>
<!-- Large Message Upload (End) -->
</services>
<behaviors>
<serviceBehaviors>
<!-- Large Message Upload (Begin) -->
<behavior name="ServiceWithMetadata">
<!-- Large Message Upload (End) -->
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true" />
</behavior>
</serviceBehaviors>
</behaviors>
...
</system.serviceModel>
...
</configuration>
As you can see there are three changes required:
1) Create a binding specifically for the service that you want to enable large file uploads for (my project publishes five services at the moment, but only one requires a larger file upload limit). Ensure that the value of the name attribute matches the name of the binding we noted in the client's web.config file. Copy the attributes and child nodes from the example above and modify as you see fit. All size values are, AKAIK, in bytes.
2) Jumping around a bit, we're going to move to the last change in the config extract next. Visual Studio creates a default behaviour node with all the correct settings, but does NOT set a name on that node, so add a name attribute and give it a value. ServiceWithMetadata was the value in the example I found, so that's what I used - I don't know if it really matters what you call it.
3) Create a service node for your service. The name must be the fully qualified name of your service class and the behaviourConfiguration needs to be the name of the service node, as set in step 2). Within the service node you'll need to configure an endpoint, the bindingConfiguration of which needs to be set to the name of the binding setup in step 1) and the contract of which needs to be set to the fully qualified name of the interface your service class adheres to.
That's it really. Figuring this out has taken far too long and I can't believe how complex the process has been or how little documentation there appears to be out there on this topic. To anyone suffering the same issue as I did: good luck! I hope that this post saves you the time I had to invest figuring this out the hard way.
I have a set of WCF services hosted on a .NET 4 application. I manually create the ServiceHost class and start listening on TCP port.
All works as expected but in the WCF trace on the server side I get the warning below.
Configuration evaluation context not found.
XML trace follows:
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>524312</EventID>
<Type>3</Type>
<SubType Name="Warning">0</SubType>
<Level>4</Level>
<TimeCreated SystemTime="2010-09-03T12:33:01.9404010Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
<Execution ProcessName="Server.Console.vshost" ProcessID="24612" ThreadID="10" />
<Channel />
<Computer>BAROLO</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning">
<TraceIdentifier>http://msdn.microsoft.com/it-IT/library/System.ServiceModel.EvaluationContextNotFound.aspx</TraceIdentifier>
<Description>Configuration evaluation context not found.</Description>
<AppDomain>Server.Console.vshost.exe</AppDomain>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>
Any idea about the reason of the warning?
Thanks
Did you take a look at that MSDN blog: Missing Binding Extensions?
The evaluation context not found error (or in traces with the identifier System.ServiceModel.EvaluationContextNotFound) is generally caused by using a configuration element defined in a library that is not included in the application’s configuration as an extension.
My experience is, you have to manually create service with service name and other details under tag.
e.g.
<system.serviceModel>
<services>
<service name="WCF_NameSpace.Service1" behaviorConfiguration="behave">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="bind" contract="WCF_Trace_2.IService1"></endpoint>
</service>
</services>