Click here to Skip to main content
15,909,498 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: GUI Interface of a service Pin
PIEBALDconsult19-Dec-06 3:22
mvePIEBALDconsult19-Dec-06 3:22 
GeneralRe: GUI Interface of a service Pin
christopheL19-Dec-06 3:58
christopheL19-Dec-06 3:58 
QuestionHow to Edit a Data Grid, using Text Box or Combobox Pin
Kushwaha2k18-Dec-06 23:53
Kushwaha2k18-Dec-06 23:53 
AnswerRe: How to Edit a Data Grid, using Text Box or Combobox Pin
kinnuP20-Dec-06 0:28
kinnuP20-Dec-06 0:28 
Questionseparate .config file Pin
knez18-Dec-06 23:05
knez18-Dec-06 23:05 
Question.Net:Globalization and SQL:Collate Pin
enduro1x18-Dec-06 18:42
enduro1x18-Dec-06 18:42 
QuestionNo Touch Deployment vs ClickOnce Deployment Pin
KreativeKai18-Dec-06 6:02
professionalKreativeKai18-Dec-06 6:02 
QuestionGetting to know WCF questions. Pin
Snowjim17-Dec-06 22:38
Snowjim17-Dec-06 22:38 
Hey!

I am building on a simple chat application that uses callbacks. The contract are created in a class library that are then referd to in myWCFCallBackHost, the contract looks like this:

Contract:
<br />
namespace myWCFCallBackService<br />
{<br />
    /// <summary><br />
    /// The interface the service exposes<br />
    /// One Session to each client<br />
    /// </summary><br />
    [ServiceContract(SessionMode=SessionMode.Required, CallbackContract = typeof(IChangedHandler))]<br />
    public interface IChat<br />
    {<br />
        //Opens a new session when executed<br />
        [OperationContract(IsOneWay=false, IsInitiating = true)]<br />
        void Subscribe(string inName);<br />
<br />
        //Close the current session bound to the current client<br />
        [OperationContract(IsOneWay = false, IsTerminating = true)]<br />
        void Unsubscribe();<br />
<br />
        //Lets the client post a message<br />
        [OperationContract(IsOneWay = true)]<br />
        void publishNewMessage(string inMessage, string inName);<br />
    }<br />
<br />
    /// <summary><br />
    /// The interface that clients must implement<br />
    /// </summary><br />
    public interface IChangedHandler<br />
    {<br />
        [OperationContract(IsOneWay = true)]<br />
        void changed(string newMessage);<br />
    }<br />
<br />
    /// <summary><br />
    /// A singelton object of the chat class to be able to subscribe clients<br />
    /// </summary><br />
    [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]<br />
    public class chat : IChat<br />
    {<br />
        private List<IChangedHandler> mSubscribers = new List<IChangedHandler>();<br />
<br />
        public chat()<br />
        {<br />
<br />
        }<br />
<br />
        public void Subscribe(string inName)<br />
        {<br />
            mSubscribers.Add(OperationContext.Current.GetCallbackChannel<IChangedHandler>());<br />
        }<br />
<br />
        public void Unsubscribe()<br />
        {<br />
            IChangedHandler caller =<br />
                OperationContext.Current.GetCallbackChannel<IChangedHandler>();<br />
<br />
            foreach (IChangedHandler ch in mSubscribers)<br />
            {<br />
                if (ch == caller)<br />
                {<br />
                    mSubscribers.Remove(ch);<br />
                    break;<br />
                }<br />
            }<br />
        }<br />
        public void publishNewMessage(string inMessage, string inName)<br />
        {<br />
            int nIndex = 0;<br />
            try<br />
            {<br />
                foreach (IChangedHandler ch in mSubscribers)<br />
                {<br />
                    ch.changed(inMessage);<br />
                    nIndex++;<br />
                }<br />
            }<br />
            catch (Exception ex)<br />
            {<br />
                mSubscribers.RemoveAt(nIndex);<br />
            }<br />
        }<br />
    }<br />
}<br />

HOST:
My Host for this class library is a windows application project(myWCFCallBackHost), the initialize method looks likes this:
<br />
        private void initializeHost()<br />
        {<br />
            Uri addr;<br />
            try<br />
            {<br />
                mChat = new chat();<br />
<br />
                addr = new Uri(ConfigurationManager.AppSettings["baseTcpTempService"]);<br />
                mServiceHost = new ServiceHost(mChat, addr);<br />
<br />
                addr = new Uri(ConfigurationManager.AppSettings["basePipeTempService"]);<br />
                mServiceHost.AddServiceEndpoint(typeof(myWCFCallBackService.IChat), new NetNamedPipeBinding(), addr);<br />
<br />
                mServiceHost.Open();<br />
               <br />
                lstStatus.Items.Insert(0, DateTime.Now.ToString() + " - Chat server is running.");<br />
            }<br />
            catch(Exception ex)<br />
            {<br />
                MessageBox.Show("Error: " + ex.Message);<br />
            }<br />
        }<br />

The app.config file in my host project looks like this:

<br />
appSettings><br />
add key="baseTcpTempService" value="net.tcp://localhost:9000/chat" /><br />
add key="basePipeTempService" value="net.pipe://localhost/chat" /><br />
/appSettings><br />
system.serviceModel><br />
services><br />
service name="TempSensor"><br />
endpoint<br />
address=""<br />
binding="netTcpBinding"<br />
contract="ITempChangedPub"<br />
/><br />
/service><br />
/services><br />
/system.serviceModel><br />

PROBLEM

Generate proxy:
I have earlyer built a simple wcf application with one client and one host, i was here using http binding.

By using the fallowing command i could get a proxy class(cs) and a output.config(app.config) for the client:

svcutil.exe http://localhost/myService?wsdl

This workt grate, the client could contact the host with no problems.

But now when I am using TCP i need to run svcutil on my assembly(dll) file from my Service project(myWCFCallBackService) like this:

svcutil.exe myWCFCallBackService.dll

And this generates two files(xsd and wsdl). Now i need to run svcutil.exe on this two files as well, but this will not work?

svcutil.exe tempuri.org.wsdl

Gets me the fallowing error:

Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.Se
rviceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://tempuri.org/' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/'
]/wsdl:portType[@name='IChat']


Error: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is de
pendent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='http://tempuri.org/
']/wsdl:portType[@name='IChat']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/'
]/wsdl:binding[@name='DefaultBinding_IChat']


Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata docu
ments did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assembl
ies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to
use the /dataContractOnly option.

And if i run:
svcutil.exe tempuri.org.xsd

I get the fallowing error:

Generating files...
Warning: No code was generated.
If you were trying to generate a client, this could be because the metadata docu
ments did not contain any valid contracts or services
or because all contracts/services were discovered to exist in /reference assembl
ies. Verify that you passed all the metadata documents to the tool.

Warning: If you would like to generate data contracts from schemas make sure to
use the /dataContractOnly option.

I was expected a proxy class(cs) and a output.config file(app.config).

What am i doing wrong?

Other Questions

1. Am I handling the callback correct?
2. Will i get a proxy class and a config file from using svutil.exe or what will i get? and how to use them?
3. From a earlier project alot of things was placed in the Hosts app.config file insted of in the code, like this:
<br />
      <?xml version="1.0" encoding="utf-8" ?><br />
      <configuration><br />
          <system.serviceModel><br />
              <behaviors><br />
                  <serviceBehaviors><br />
                      <behavior name="myServiceTypeBehavior"><br />
                          <serviceMetadata httpGetEnabled="True"/><br />
                      </behavior><br />
                  </serviceBehaviors><br />
              </behaviors><br />
              <services><br />
                  <service name="myWCFServerObjectSender.personService" behaviorConfiguration="myServiceTypeBehavior"><br />
                      <endpoint address="http://localhost/person"<br />
                                binding="basicHttpBinding"<br />
                                contract="myWCFServerObjectSender.personService"><br />
                      </endpoint><br />
                      <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /><br />
                  </service><br />
              </services><br />
          </system.serviceModel><br />
      </configuration><br />

Is it posible to do somthing like this with the current project? and if, how should it look like?.

Sorry for all the questions but i am learning the intressting WCF framework.
Questionclasses Pin
chinnivinay17-Dec-06 19:38
chinnivinay17-Dec-06 19:38 
AnswerRe: classes Pin
Guffa17-Dec-06 21:28
Guffa17-Dec-06 21:28 
AnswerRe: classes Pin
ednrgc20-Dec-06 7:34
ednrgc20-Dec-06 7:34 
Questioninterfaces Pin
chinnivinay17-Dec-06 19:37
chinnivinay17-Dec-06 19:37 
AnswerRe: interfaces Pin
Guffa17-Dec-06 21:28
Guffa17-Dec-06 21:28 
GeneralRe: interfaces Pin
karam chandrabose18-Dec-06 5:54
karam chandrabose18-Dec-06 5:54 
AnswerRe: interfaces Pin
ednrgc20-Dec-06 7:34
ednrgc20-Dec-06 7:34 
QuestionReporting Pin
Ray Cassick17-Dec-06 8:41
Ray Cassick17-Dec-06 8:41 
Questionremember me on same computer!!! Pin
Ashish Porwal15-Dec-06 20:15
Ashish Porwal15-Dec-06 20:15 
AnswerRe: remember me on same computer!!! Pin
MatrixCoder15-Dec-06 20:20
MatrixCoder15-Dec-06 20:20 
AnswerRe: remember me on same computer!!! Pin
ednrgc20-Dec-06 7:35
ednrgc20-Dec-06 7:35 
GeneralRe: remember me on same computer!!! Pin
toxcct22-Jan-07 9:12
toxcct22-Jan-07 9:12 
QuestionFtpConnection Pin
shinajoon15-Dec-06 18:37
shinajoon15-Dec-06 18:37 
Questiondifference b/w manifest and metadata? Pin
Rahithi15-Dec-06 15:31
Rahithi15-Dec-06 15:31 
AnswerRe: difference b/w manifest and metadata? Pin
karam chandrabose18-Dec-06 18:00
karam chandrabose18-Dec-06 18:00 
Question! character appearing in long strings Pin
Fred_Smith15-Dec-06 13:54
Fred_Smith15-Dec-06 13:54 
AnswerRe: ! character appearing in long strings Pin
Luc Pattyn16-Dec-06 15:25
sitebuilderLuc Pattyn16-Dec-06 15:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.