Solved

Web Service Error With .dll

Posted on 2014-12-27
3
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 36

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

752 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