Solved

Web Service Error With .dll

Posted on 2014-12-27
3
226 Views
Last Modified: 2014-12-28
Hi All,

I am developing a dll using dot net windows application, in this project i am using the webservice to send the xml data to third party server and fetching the response from that third party server.  When i am using this .dll into some other application then i am getting the below error:

Could not find default endpoint element that references contract 'abc.xyz' in the service model client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract cound be found in the client element.

Below is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Net;
using System.IO;
using testwebservices.PCWeno;

namespace testwebservices
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
          
            this.CallWeno();
        }

        private void CallWeno()
        {
            try
            {
                Security sec = new Security();

                sec.UserName = "a";
                sec.Password = "b";
                SoapBodyNCPDP sbbody = new SoapBodyNCPDP();

                string str = "";
                str += ("<?xml version='1.0' encoding='utf-8'?>");
                str += ("<Message version='010' release='006' xmlns='https://wexlb.wenoexchange.com/schema/SCRIPT' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>");
                str += ("<Header>");
                str += ("<To Qualifier='P'>1234567</To>");
                str += ("<From Qualifier='D'>D89799:C29230</From>");
                str += ("<MessageID>" + "TestKPL5" + "</MessageID>");
                str += ("<SentTime>" + Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyy-MM-ddThh:mm:ss") + "</SentTime>");
                str += ("<Mailbox>");
                str += ("<DeliveredID>Sample Software Product Version 3</DeliveredID>");
                str += ("</Mailbox>");
                str += ("</Header>");
                str += ("<Body>");
                str += ("<NewRx>");
                str += ("<Pharmacy>");
                str += ("<Identification>");
                str += ("<NCPDPID>9999999</NCPDPID>");
                str += ("</Identification>");
                str += ("<StoreName>" + "CVS" + "</StoreName>");
                str += ("<CommunicationNumbers>");
                str += ("<Communication>");
                str += ("<Number>" + "19493635880" + "</Number>");
                str += ("<Qualifier>TE</Qualifier>");
                str += ("</Communication>");
                str += ("</CommunicationNumbers>");
                str += ("</Pharmacy>");
                str += ("<Prescriber>");
                str += ("<Identification>");
                str += ("<NPI>13892</NPI>");
                str += ("</Identification>");
                str += ("<Name>");
                str += ("<LastName>" + "Surana" + "</LastName>");
                str += ("<FirstName>" + "Hemesh" + "</FirstName>");
                str += ("</Name>");
                str += ("<Address>");
                str += ("<AddressLine1>123 Tarzan Road</AddressLine1>");
                str += ("<City>Devine</City>");
                str += ("<State>TX</State>");
                str += ("<ZipCode>78016</ZipCode>");
                str += ("</Address>");
                str += ("<CommunicationNumbers>");
                str += ("<Communication>");
                str += ("<Number>8892224567</Number>");
                str += ("<Qualifier>TE</Qualifier>");
                str += ("</Communication>");
                str += ("</CommunicationNumbers>");
                str += ("</Prescriber>");
                str += ("<Patient>");
                str += ("<Name>");
                str += ("<LastName>" + "Surana" + "</LastName>");
                str += ("<FirstName>" + "Hemesh" + "</FirstName>");
                str += ("</Name>");
                str += ("<Gender>" + "M" + "</Gender>");
                str += ("<DateOfBirth>");
                str += ("<Date>" + "2014-12-31" + "</Date>");
                str += ("</DateOfBirth>");
                str += ("<Address>");
                str += ("<AddressLine1>test</AddressLine1>");
                str += ("<City>test</City>");
                str += ("<State>TX</State>");
                str += ("</Address>");
                str += ("</Patient>");
                str += ("<MedicationPrescribed>");
                str += ("<DrugDescription>" + "Test" + "</DrugDescription>");
                str += ("<DrugCoded>");
                str += ("<ProductCode>2989</ProductCode>");
                str += ("<ProductCodeQualifier>ND</ProductCodeQualifier>");
                str += ("<DrugDBCode>989892</DrugDBCode>");
                str += ("<DrugDBCodeQualifier>MD</DrugDBCodeQualifier>");
                str += ("<DEASchedule>NONE</DEASchedule>");
                str += ("</DrugCoded>");
                str += ("<Quantity>");
                str += ("<Value>30</Value>");
                str += ("<CodeListQualifier>38</CodeListQualifier>");
                str += ("<UnitSourceCode>AC</UnitSourceCode>");
                str += ("<PotencyUnitCode>C38016</PotencyUnitCode>");
                str += ("</Quantity>");
                str += ("<Directions>" + "Tsest" + "</Directions>");
                str += ("<Refills>");
                str += ("<Qualifier>R</Qualifier>");
                str += ("<Value>0</Value>");
                str += ("</Refills>");
                str += ("<WrittenDate>");
                str += ("<Date>" + "2014-12-31" + "</Date>");
                str += ("</WrittenDate>");
                str += ("<EffectiveDate>");
                str += ("<Date>" + "2014-12-31" + "</Date>");
                str += ("</EffectiveDate>");
                str += ("<DrugCoverageStatusCode>UN</DrugCoverageStatusCode>");
                str += ("</MedicationPrescribed>");
                str += ("</NewRx>");
                str += ("</Body>");
                str += ("</Message>");
                var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(str);
                sbbody.Payload = System.Convert.ToBase64String(plainTextBytes);
                
                ServiceSoapClient CallWebService = new ServiceSoapClient();
                
                sbbody = CallWebService.RealTimeTransactionNCPDP(ref sec, sbbody);
                str = Encoding.UTF8.GetString(Convert.FromBase64String(sbbody.Payload)).Replace("><", ">\n<");
                label1.Text = str.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
}
}

Open in new window


Please help me to solve this problem.

Thanks in advance

Regards
0
Comment
Question by:Jatin Nahar
3 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 40520057
You are missing the configuration file from your DLL that defines the web service client configuration.
The solution is simple. Copy the endpoint definitions from the config file (e.g. ServiceReferences.ClientConfig) of the DLL project to the config file of your application.
Note: When you add the web service reference to your DLLproject, the app.config file is appended with the web service connection details.
0
 

Author Closing Comment

by:Jatin Nahar
ID: 40521376
excellent solution
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question