Solved

Web Service Error With .dll

Posted on 2014-12-27
3
229 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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