Solved

Web Service Error With .dll

Posted on 2014-12-27
3
213 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
Comment Utility
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
Comment Utility
excellent solution
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

728 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now