Hallo allerseits,
ich möchte momentan in einem Web Service auf eine Methode aus einem anderen Web Service zugreifen. Allerdings bekomme ich jedes Mal, an der Stelle, an der der eine Web Service eine neue Instanz des anderen Webservice öffnen möchte folgende Fehlermeldung:
Um die Möglichen Probleme zu reduzieren habe ich einen sehr einfachen Versuchsaufbau gemacht, bei dem dasselbe Problem auftritt:
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace Service1
{
[ServiceContract]
public interface IService1
{
[OperationContract]
String print();
}
}
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Service1
{
public class Service1 : IService1
{
#region IService1 Member
public string print()
{
return "Service1";
}
#endregion
}
}
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (ServiceHost serviceHost1 = new ServiceHost(typeof(Service1.Service1)))
{
serviceHost1.Open();
Console.WriteLine("{0} is read.", "Service1");
Console.WriteLine("Press the Enter key to terminate Service.");
Console.ReadLine();
}
}
}
}
[/highlight]
[highlight= XML]
<-- App.config (Service1Host)-->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="Service1.Service1"
behaviorConfiguration="Service1MEXBehavior" >
<endpoint address=""
binding="basicHttpBinding"
contract="Service1.IService1"/>
<!--Enable the MEX endpoint-->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<!--Need to add this so MEX knows the adress of our service-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Service1"/>
</baseAddresses>
</host>
</service>
</services>
<!--A behavior definition for MEX-->
<behaviors>
<serviceBehaviors>
<behavior name="Service1MEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace Service2
{
[ServiceContract]
public interface IService2
{
[OperationContract]
String print();
}
}
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service1.ServiceReference1;
namespace Service2
{
public class Service2 : IService2
{
#region IService1 Member
public string print()
{
Service1Client client = new Service1Client(); // Fehlermeldung return "Service1: " + client.print();
}
#endregion
}
}
[/highlight]
[highlight=xml]
<-- app.config (Service2 ref Service1) -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/Service1" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (ServiceHost serviceHost1 = new ServiceHost(typeof(Service2.Service2)))
{
serviceHost1.Open();
Console.WriteLine("{0} is read.", "Service2");
Console.WriteLine("Press the Enter key to terminate Service.");
Console.ReadLine();
}
}
}
}
[/highlight]
[highlight=xml]
<--app.config (Service2 Host) -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="Service2.Service2"
behaviorConfiguration="Service2MEXBehavior" >
<endpoint address=""
binding="basicHttpBinding"
contract="Service2.IService2"/>
<!--Enable the MEX endpoint-->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<!--Need to add this so MEX knows the adress of our service-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Service2"/>
</baseAddresses>
</host>
</service>
</services>
<!--A behavior definition for MEX-->
<behaviors>
<serviceBehaviors>
<behavior name="Service2MEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service12Client.ServiceReference1;
namespace Service12Client
{
class Program
{
static void Main(string[] args)
{
Service2Client client = new Service2Client();
Console.WriteLine(client.print());
Console.ReadLine();
}
}
}
[/highlight]
[highlight=xml]
<--app.config (Client)-->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService2" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/Service2" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference1.IService2"
name="BasicHttpBinding_IService2" />
</client>
</system.serviceModel>
</configuration>
[/highlight]
Kann mir da jemand weiterhelfen?
Mit freundlichen Grüßen,
Athlone
ich möchte momentan in einem Web Service auf eine Methode aus einem anderen Web Service zugreifen. Allerdings bekomme ich jedes Mal, an der Stelle, an der der eine Web Service eine neue Instanz des anderen Webservice öffnen möchte folgende Fehlermeldung:
Originally posted by InvalidOperationExcption wunde nicht vom Benutzercode behandelt.
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace Service1
{
[ServiceContract]
public interface IService1
{
[OperationContract]
String print();
}
}
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Service1
{
public class Service1 : IService1
{
#region IService1 Member
public string print()
{
return "Service1";
}
#endregion
}
}
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (ServiceHost serviceHost1 = new ServiceHost(typeof(Service1.Service1)))
{
serviceHost1.Open();
Console.WriteLine("{0} is read.", "Service1");
Console.WriteLine("Press the Enter key to terminate Service.");
Console.ReadLine();
}
}
}
}
[/highlight]
[highlight= XML]
<-- App.config (Service1Host)-->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="Service1.Service1"
behaviorConfiguration="Service1MEXBehavior" >
<endpoint address=""
binding="basicHttpBinding"
contract="Service1.IService1"/>
<!--Enable the MEX endpoint-->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<!--Need to add this so MEX knows the adress of our service-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Service1"/>
</baseAddresses>
</host>
</service>
</services>
<!--A behavior definition for MEX-->
<behaviors>
<serviceBehaviors>
<behavior name="Service1MEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.ServiceModel;
namespace Service2
{
[ServiceContract]
public interface IService2
{
[OperationContract]
String print();
}
}
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service1.ServiceReference1;
namespace Service2
{
public class Service2 : IService2
{
#region IService1 Member
public string print()
{
Service1Client client = new Service1Client(); // Fehlermeldung return "Service1: " + client.print();
}
#endregion
}
}
[/highlight]
[highlight=xml]
<-- app.config (Service2 ref Service1) -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/Service1" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
using (ServiceHost serviceHost1 = new ServiceHost(typeof(Service2.Service2)))
{
serviceHost1.Open();
Console.WriteLine("{0} is read.", "Service2");
Console.WriteLine("Press the Enter key to terminate Service.");
Console.ReadLine();
}
}
}
}
[/highlight]
[highlight=xml]
<--app.config (Service2 Host) -->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="Service2.Service2"
behaviorConfiguration="Service2MEXBehavior" >
<endpoint address=""
binding="basicHttpBinding"
contract="Service2.IService2"/>
<!--Enable the MEX endpoint-->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<!--Need to add this so MEX knows the adress of our service-->
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Service2"/>
</baseAddresses>
</host>
</service>
</services>
<!--A behavior definition for MEX-->
<behaviors>
<serviceBehaviors>
<behavior name="Service2MEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
[/highlight]
[highlight=c#]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service12Client.ServiceReference1;
namespace Service12Client
{
class Program
{
static void Main(string[] args)
{
Service2Client client = new Service2Client();
Console.WriteLine(client.print());
Console.ReadLine();
}
}
}
[/highlight]
[highlight=xml]
<--app.config (Client)-->
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService2" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/Service2" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference1.IService2"
name="BasicHttpBinding_IService2" />
</client>
</system.serviceModel>
</configuration>
[/highlight]
Kann mir da jemand weiterhelfen?
Mit freundlichen Grüßen,
Athlone
Comment