I am in the same boat as both of you in regards to the inability to simply comment. Great explanation on transmitting to the IRS. It seems there are a few of us working on this site working on this same project for our respective entities.
However, I am running into the following error, and am having trouble determining the next steps to resolve it. I am receiving this error when instantiating the BulkRequestTransmitterPortTypeClient
to a new object so that I can add the Content-Encoding
to the header and send the request to the IRS.
An unhandled exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
Additional information: The type 'GZipEncoder.GzipMessageEncodingElement, GZipEncoder' registered for extension 'gzipMessageEncoding' could not be loaded.
- I have created a new Project in my solution and created the three class files from the Encoding sample.
- I made the changes you outlined to my code.
- Added this project as a reference in my Client application.
- In my client application, the
gzipMessageEncoding
app.config
entry is underlined, but from other posts I have read, this is okay.
- I have what I believe are the appropriate
<extensions><bindingElementExtensions>
and <metadata><policyImporters><extension>
entries in my app.config
.
Answer-Edit
To overcome the error I was having, I found this post which led me to use the following code to output the type strings that I needed to add to the app.config
. I copied the strings output by these commands into the app.config
and that got me past the error above.
Console.WriteLine(typeof(GZipEncoder.GZipMessageEncodingElement).AssemblyQualifiedName);
Console.WriteLine(typeof(GZipEncoder.GZipMessageEncodingBindingElementImporter).AssemblyQualifiedName);
app.config entries
<system.serviceModel>
<extensions>
<bindingElementExtensions>
<add name="gzipMessageEncoding" type="GZipEncoder.GZipMessageEncodingElement, GZipMessageEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</bindingElementExtensions>
</extensions>
<client>
<metadata>
<policyImporters>
<extension type="GZipEncoder.GZipMessageEncodingBindingElementImporter, GZipMessageEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</policyImporters>
</metadata>
</client>
<bindings>
<customBinding>
<binding name="BulkRequestTransmitterBinding">
<gzipMessageEncoding innerMessageEncoding="textMessageEncoding" />
<httpsTransport />
</binding>
</customBinding>
</bindings>
</system.serviceModel>
I still receive a schema validation warning on the gzipMessageEncoding
element, but a lot of things I've seen have said that is supposed to be the case. So for now, I'm going to ignore it.
Request Submission
// Called from the main method.
// 'request' is the BulkRequestTransmitterRequest object where the BusinessHeader,
// Manifest, Security, and FormData are set.
ACABulkRequestTransmitterResponseType response = SubmitRequest(request).ACABulkRequestTransmitterResponse;
private static BulkRequestTransmitterResponse SubmitRequest(BulkRequestTransmitterRequest request)
{
// Create a new instance of the Web Service client object.
BulkRequestTransmitterPortTypeClient client = new BulkRequestTransmitterPortTypeClient("BulkRequestTransmitterPort");
using (new OperationContextScope(client.InnerChannel))
{
// Add a HTTP Header to an outgoing requqest.
HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
requestMessage.Headers["Content-Encoding"] = "gzip";
OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;
return client.BulkRequestTransmitter(request);
}
}
Next onto the next fault which I am receiving on the TransmitterRequest
and StatusRequest
:
Additional information: The WS Security Header in the message is invalid.