I get the response from a web service when I send data; I've received the following response:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" SOAP-ENV:mustUnderstand="1">
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-478012">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="SOAP-ENV"/>
</ds:CanonicalizationMethod>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#id-478011">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/>
</ds:Transform>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>gPOXTVuXDw2ktXu3Fiyjoz35JwY=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>e7AOmryll5EXw3euAOlO2CwL+N3wpR+QHz8Zmlz+hBFZ7kmQ9QXkupO+MUkDrnHu/MsOZr7Q0j60heMbM4u3yIiTRPE0HsEOV1BQ/+v0LX+XSGo1EiHlcYbEo8Yn+aHFmR4z81TV8TycRXMBUoyJXl2Y/yLjFPH8TptpKLagEOYgcJQ340Cw7rVBfG+tuVwU388F/MDiv/vRhIjpHViSHSP8C7xO5NZvNoGsg5f66ATzkwkB4wmeAmHud3Mbuj7Vdq3Sw==</ds:SignatureValue>
<ds:KeyInfo Id="KI-0ACB9EF7167DC955151536323314584358508">
<wsse:SecurityTokenReference wsu:Id="STR-0ACB9EF7167DC955151536323314584358509">
<ds:X509Data>
<ds:X509IssuerSerial>
<ds:X509IssuerName>CN=AC SUB CERTICAMARA,O=CERTICAMARA S.A,OU=NIT 830084433-7,C=CO,ST=DISTRITO CAPITAL,L=BOGOTA,STREET=www.certicamara.com</ds:X509IssuerName>
<ds:X509SerialNumber>91436926122049919406185072624124</ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</wsse:SecurityTokenReference>
</ds:KeyInfo>
</ds:Signature>
<wsu:Timestamp wsu:Id="TS-478010">
<wsu:Created>2018-09-07T12:28:34.584Z</wsu:Created>
<wsu:Expires>2018-09-07T12:33:34.584Z</wsu:Expires>
</wsu:Timestamp>
<wsse11:SignatureConfirmation xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" wsu:Id="SC-478009"/>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-478011">
<ns2:EnvioFacturaElectronicaRespuesta xmlns:ns2="http://www.lodeg.gov.co/services/felectronica/ReportarFactura" xmlns:ns3="http://www.lodeg.gov.co/services/felectronica/ConsultaDocumentos" xmlns:ns4="http://www.lodeg.gov.co/services/felectronica/VersionDespliegue">
<ns2:Version>Componente lodeg</ns2:Version>
<ns2:ReceivedDateTime>2018-09-07T07:28:34.392-05:00</ns2:ReceivedDateTime>
<ns2:ResponseDateTime>2018-09-07T07:28:34.583-05:00</ns2:ResponseDateTime>
<ns2:Response>200</ns2:Response>
<ns2:Comments>Ejemplar recibido exitosamente pasará a verificación.</ns2:Comments>
</ns2:EnvioFacturaElectronicaRespuesta>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It seems that dot net expects a response without a signature.
What I have tried:
Is Not an Elegant solution, allows to continue with the process of reception of the response and its corresponding process. I had to use a CustomEncoder, in order to process the response before it arrived to eliminate the entire signature. Base on this blog https://blogs.msdn.microsoft.com/dsnotes/2016/03/08/wcf-custom-encoder-to-read-mtom-response/
public override Message ReadMessage(ArraySegment<byte> buffer, BufferManager bufferManager, string contentType)
{
byte[] incomingResponse = buffer.Array;
incomingResponse = RemoveSignatures(incomingResponse);
........
and a method...
private byte[] RemoveSignatures(byte[] stream)
{
string stream2 = Encoding.UTF8.GetString(stream);
stream2 = stream2.Replace("\0", "");
Regex x = new Regex("(\\<SOAP-ENV:Header\\>)(.*?)(\\</SOAP-ENV:Header\\>)");
string repl = "";
stream2 = x.Replace(stream2, "$1" + repl + "$3");
byte[] streamNuevo = Encoding.ASCII.GetBytes(stream2);
return streamNuevo;
}
this lines are where I recived the signed Response:
AcuseRecibo acuseRecibo = new AcuseRecibo();
acuseRecibo = Service.EnvioFacturaElectronica(envioFacturaElectronicaPeticion.EnvioFacturaElectronicaPeticion1);
return acuseRecibo.Comments.ToString();
The question, where implement ReadMessage Method???