如何从移动应用程序调用WCF服务(错误)

问题描述:


大家好
在http://localhost/Server/GreetingService上没有侦听终结点的端点可以接受该消息.这通常是由错误的地址或SOAP操作引起的

当我尝试运行wcf服务的移动应用程序客户端时,此错误弹出给我

我提出了所有要求:
1-服务(问候服务)
这是app.config
中的代码

hi all
There was no endpoint listening at http://localhost/Server/GreetingService that could accept the message. This is often caused by an incorrect address or SOAP action

this error pop up to me when i tried to run the mobile application client of wcf service

I made all requirement :
1- service ( greeting service )
this is the code in app.config

<pre lang="xml"><system.serviceModel>
    <bindings />
    <client>
      <endpoint binding="basicHttpBinding" contract="Server.IGreetingService" />
    </client>
    <services>
      <service behaviorConfiguration="Server.Service1Behavior" name="Server.Greeting_Service">
        <endpoint address="GreetingService" binding="basicHttpBinding"
          bindingConfiguration="" contract="Server.IGreetingService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8731/Design_Time_Addresses/Server/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Server.Service1Behavior">
          <!-- To avoid disclosing metadata information,
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes,
          set the value below to true.  Set to false before deployment
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>





2-我创建了网站来托管服务

这是web.conf
中的代码





2- i created website to host service

this is the code in web.conf

<pre lang="xml">system.serviceModel>
        <services>
            <service behaviorConfiguration="ServiceBehavior" name="Server.Greeting_Service">
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="" contract="Server.IGreetingService">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
                    <serviceMetadata httpGetEnabled="true"/>
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
    <system.codedom>
    </system.codedom>
    <system.web>
        <compilation debug="true">
        </compilation>



3-我在IIS上托管服务网站
这是服务的网址:
http://localhost/websitewcf/Greeting.svc [



3- i host the website of service on IIS
and this is the the url of service :
http://localhost/websitewcf/Greeting.svc[^]

4- genrate the code for proxy by powertoys
by the url for the service hosted in IIS

5- put this code in my form

System.ServiceModel.Channels.Binding binding = GreetingServiceClient.CreateDefaultBinding();
            string address = GreetingServiceClient.EndpointAddress.Uri.ToString();
            GreetingServiceClient m_proxy = new GreetingServiceClient(binding, new EndpointAddress(address));
            string result = m_proxy.Greet(textBox1.Text).ToString();
            textBox2.Text = result;      



当我尝试运行移动应用程序时,会出现此错误

在http://localhost/Server/GreetingService上没有侦听终结点的端点可以接受该消息.这通常是由错误的地址或SOAP操作引起的.



and when i try to run the mobile app this error is appear

There was no endpoint listening at http://localhost/Server/GreetingService that could accept the message. This is often caused by an incorrect address or SOAP action

更正端点.如果您将服务托管在计算机上,请使用计算机名称代替localhost,服务应该可以正常工作.
Correct the endpoint. If you have hosted your service on a computer, put the computer''s name in stead of localhost and the service should work.


更正端点.如果您已在计算机上托管服务,请使用计算机名称代替localhost,并且该服务应能正常工作.


是的,我在我的计算机Windows Vista SP1中托管了我的服务

我把电脑的名字放在
Correct the endpoint. If you have hosted your service on a computer, put the computer''s name in stead of localhost and the service should work.


yes i hosted my service in my computer windows vista sp1

i puted the computer''s name in
<host>
       <baseAddresses>
         <add baseAddress="http://localhost:ashrafelhakim/Design_Time_Addresses/Server/Service1/" />
       </baseAddresses>
     </host>




服务无法运行.

当我尝试在此计算机名称中输入
公共静态System.ServiceModel.EndpointAddress EndpointAddress =新的System.ServiceModel.EndpointAddress("http://AshrafEL-Hakim/websitewcf/Greeting.svc");

同样的错误.
当我尝试将其更改为
我想你是说这个:
http://localhost:AshrafEl-hakim/webwebsitewcf/Greeting.svc);
同样的错误:(


我理解你的正确与否?很抱歉
但实际上我需要您的帮助:(




the service can''t run.

and when i try to put the computer name in this
public static System.ServiceModel.EndpointAddress EndpointAddress = new System.ServiceModel.EndpointAddress("http://AshrafEL-Hakim/websitewcf/Greeting.svc");

the same error.
and when i try to change it to
and i think u mean this :
http://localhost:AshrafEl-hakim/webwebsitewcf/Greeting.svc");
the same error too :(


i understood u correct or not ? am sry
but really i need ur help :(


以下内容看起来不错:http://AshrafEL-Hakim/websitewcf/Greeting.svc

现在,由于您的手机和计算机不在同一网络中,因此它们将无法交互.为了使他们彼此交谈,您可以使用互联网.为此,您需要了解如何才能通过Internet公开服务. [ ^ ]可能是一个不错的开始.如果只想检查服务是否运行正常,请在计算机中创建一个简单的移动应用程序,然后尝试调用服务操作.
Following looks fine: http://AshrafEL-Hakim/websitewcf/Greeting.svc

Now, since your mobile and your computer are not in same network, they will not be able to interact. In order to make them talk to each other, you can make use of internet. For that, you would need to understand how can we expose a service over internet. This[^] might be a good start. If you just want to check if your service is working fine, create a simple mobile application in your computer and then try to call service operation.