Ejemplo n.º 1
0
        public EncodeResponseType Encode(EncodeRequestType request)
        {
            Message requestMsg  = Message.CreateMessage(MessageVersion.Soap11, "http://www.ehealth.be/webservices/cod/encode", request, new XmlSerializerObjectSerializer(typeof(EncodeRequestType)));
            Message responseMsg = base.Channel.Request(requestMsg);

            if (responseMsg.IsFault)
            {
                throw new FaultException(MessageFault.CreateFault(responseMsg, 1024));
            }
            return(responseMsg.GetBody <EncodeResponseType>(new XmlSerializerObjectSerializer(typeof(EncodeResponseType))));
        }
Ejemplo n.º 2
0
        private static void DoTest(CodageClient client)
        {
            //Do encoding
            OriginalDataType org1 = new OriginalDataType();
            org1.randomize = false;
            org1.id = "1";
            org1.inputData = "79021802145";

            OriginalDataType org2 = new OriginalDataType();
            org2.randomize = true;
            org2.id = "2";
            org2.inputData = "0459540270";

            EncodeRequestType encReq = new EncodeRequestType();
            encReq.applicationName = "Test";
            encReq.originalData = new OriginalDataType[] { org1, org2 };

            EncodeResponseType encResp = client.Encode(encReq);

            //Verify encoding result
            Assert.IsFalse(string.IsNullOrWhiteSpace(encResp.ticketNumber));
            if (encResp.globalError != null) Assert.Fail(encResp.globalError.errorValue);
            Assert.AreEqual(encReq.applicationName, encResp.applicationName);

            IEnumerable<ErrorType> encErrors = from r in encResp.response where r.error != null select r.error;
            Assert.Equals(0, encErrors.Count());
            //Here you normaly check the errors, but since it is only a test it fails right here

            EncodedDataType encDetail1 = (from r in encResp.response where r.encodedData != null && r.encodedData.id == "1" select r.encodedData).Single();
            Assert.IsNotNull(encDetail1.value);
            Assert.AreNotEqual(0, encDetail1.value.Length);

            EncodedDataType encDetail2 = (from r in encResp.response where r.encodedData != null && r.encodedData.id == "2" select r.encodedData).Single();
            Assert.IsNotNull(encDetail2.value);
            Assert.AreNotEqual(0, encDetail2.value.Length);

            //Do decoding
            EncodedDataType enc1 = new EncodedDataType();
            enc1.id = "1";
            enc1.value = encDetail1.value;

            EncodedDataType enc2 = new EncodedDataType();
            enc2.id = "2";
            enc2.value = encDetail2.value;

            DecodeRequestType decReq = new DecodeRequestType();
            decReq.applicationName = "Test";
            decReq.encodedData = new EncodedDataType[] { enc1, enc2 };

            DecodeResponseType decResp = client.Decode(decReq);
            Assert.IsFalse(string.IsNullOrWhiteSpace(decResp.ticketNumber));
            if (decResp.globalError != null) Assert.Fail(decResp.globalError.errorValue);

            IEnumerable<ErrorType> decErrors = from r in decResp.response where r.error != null select r.error;
            Assert.AreEqual(0, decErrors.Count());
            //Here you normaly check the errors, but since it is only a test it fails right here

            DecodedDataType decDetail1 = (from r in decResp.response where r.decodedData != null && r.decodedData.id == "1" select r.decodedData).Single();
            Assert.AreEqual(org1.inputData, decDetail1.outputData);

            DecodedDataType decDetail2 = (from r in decResp.response where r.decodedData != null && r.decodedData.id == "2" select r.decodedData).Single();
            Assert.AreEqual(org2.inputData, decDetail2.outputData);
        }