?
Solved

Web Service Error With .dll

Posted on 2014-12-27
3
Medium Priority
?
246 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 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