Skip to content
Browse files

Merge branch 'RemoteAPI_MetadataExchange'

  • Loading branch information...
2 parents 34b670c + e6c4633 commit ad3a81832b978a9244a3af131afaccdb81cb5905 Markus Zorn committed Nov 3, 2011
View
2 Applications/TagExampleWithGraphMappingFramework/Example.cs
@@ -203,7 +203,7 @@ public virtual void OnCancelKeyPress(object sender, ConsoleCancelEventArgs e)
public void Run()
{
- GraphDSClient = new GraphDS_RemoteClient(new Uri("http://localhost:9970/rpc"), true);
+ GraphDSClient = new GraphDS_RemoteClient(new Uri("https://localhost:9970/rpc"), true);
SecToken = GraphDSClient.LogOn(new RemoteUserPasswordCredentials("test", "test"));
TransToken = GraphDSClient.BeginTransaction(SecToken);
View
2 Applications/sonesGraphDB/sonesGraphDBStarter.cs
@@ -235,7 +235,7 @@ public sonesGraphDBStartup(String[] myArgs)
Dictionary<string, object> RemoteAPIParameter = new Dictionary<string, object>();
RemoteAPIParameter.Add("IPAddress", IPAddress.Any);
RemoteAPIParameter.Add("Port", (ushort)9970);
- RemoteAPIParameter.Add("IsSecure", true);
+ //RemoteAPIParameter.Add("IsSecure", true);
_dsServer.StartService("sones.RemoteAPIService", RemoteAPIParameter);
#endregion
View
4 GraphDS/Client/Implementations/GraphDSRemoteClient/GraphDS_RemoteClient.cs
@@ -75,9 +75,9 @@ public GraphDS_RemoteClient(Uri myServiceAddress, bool myIsSecure = false)
try
{
- //not suitable for checking secured connections
+ //request to test connection
var Request = HttpWebRequest.Create(myServiceAddress.ToString());
- //var Response = Request.GetResponse();
+ var Response = Request.GetResponse();
}
catch (Exception ex)
{
View
4 Plugins/GraphDS/Services/Implementations/RemoteAPIService/RemoteAPIService.cs
@@ -85,9 +85,9 @@ public void Start(IDictionary<string, object> myStartParameter = null)
_RunningTime.Start();
_RPCServer = new sonesRPCServer(_GraphDS, Address, Port, UriPattern, _IsSecure);
_RPCServer.StartServiceHost();
- _description = " * RemoteAPI Service is started at " + ((_IsSecure == true) ? "https://" : "http://") + Address + ":" + Port + Environment.NewLine +
+ _description = " * RemoteAPI Service is started at " + _RPCServer.URI + Environment.NewLine +
" * web service definition can be found at " + Environment.NewLine +
- " " + ((_IsSecure == true) ? "https://" : "http://") + Address + ":" + Port + "/mex" + Environment.NewLine +
+ " " + _RPCServer.MexUri + "/wsdl" + Environment.NewLine +
" * default username and passwort: test / test ";
}
catch (Exception Ex)
View
6 Plugins/GraphDS/Services/Implementations/RemoteAPIService/RemoteAPIService.csproj
@@ -109,7 +109,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RemoteAPIService.cs" />
<Compile Include="ServiceContractImplementation\StreamedService.cs" />
- <Compile Include="ServiceContracts\MonoMEX\MonoMEX.cs" />
+ <Compile Include="ServiceContracts\MEX\MonoMEX.cs" />
<Compile Include="ServiceContractImplementation\EdgeService.cs" />
<Compile Include="ServiceContractImplementation\EdgeTypeService.cs" />
<Compile Include="ServiceContractImplementation\GraphDS_API.cs" />
@@ -120,7 +120,7 @@
<Compile Include="ServiceContracts\EdgeInstanceService\IEdgeService.cs" />
<Compile Include="ServiceContracts\EdgeTypeServices\IEdgeTypeService.cs" />
<Compile Include="ServiceContracts\IRPCServiceContract.cs" />
- <Compile Include="ServiceContracts\MonoMEX\IMonoMEX.cs" />
+ <Compile Include="ServiceContracts\MEX\IMonoMEX.cs" />
<Compile Include="ServiceContracts\StreamedService\IStreamedService.cs" />
<Compile Include="ServiceContracts\VertexInstanceService\IVertexService.cs" />
<Compile Include="ServiceContracts\VertexTypeServices\IVertexTypeService.cs" />
@@ -189,7 +189,7 @@
<Folder Include="ServiceStatus\" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="ServiceContracts\MonoMEX\WSDL.xml">
+ <EmbeddedResource Include="ServiceContracts\MEX\WSDL.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
View
2 ...vice/ServiceContracts/MonoMEX/IMonoMEX.cs → ...IService/ServiceContracts/MEX/IMonoMEX.cs
@@ -6,7 +6,7 @@
using System.ServiceModel.Web;
using System.IO;
-namespace sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MonoMEX
+namespace sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MEX
{
[ServiceContract(Namespace = sonesRPCServer.Namespace)]
public interface IMonoMEX
View
6 ...rvice/ServiceContracts/MonoMEX/MonoMEX.cs → ...PIService/ServiceContracts/MEX/MonoMEX.cs
@@ -31,7 +31,7 @@
using sones.GraphDS.Services.RemoteAPIService.ServiceContracts;
using sones.GraphDS.Services.RemoteAPIService.DataContracts;
using sones.Library.Commons.Security;
-using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MonoMEX;
+using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MEX;
using System.Reflection;
using System.IO;
using System.Xml;
@@ -45,11 +45,10 @@ namespace sones.GraphDS.Services.RemoteAPIService.ServiceContractImplementation
[ServiceBehavior(Namespace = sonesRPCServer.Namespace, IncludeExceptionDetailInFaults = true)]
public class MonoMEX : IMonoMEX
{
-
public Stream GetWSDL()
{
- var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MonoMEX.WSDL.xml");
+ var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MEX.WSDL.xml");
OutgoingWebResponseContext context = WebOperationContext.Current.OutgoingResponse;
@@ -59,7 +58,6 @@ public Stream GetWSDL()
context.ContentType = "application/xml";
context.StatusCode = System.Net.HttpStatusCode.OK;
return stream;
-
}
}
}
View
2,107 ...Service/ServiceContracts/MonoMEX/WSDL.xml → ...eAPIService/ServiceContracts/MEX/WSDL.xml
1,322 additions, 785 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
87 Plugins/GraphDS/Services/Implementations/RemoteAPIService/sonesRPCServer.cs
@@ -33,7 +33,7 @@
using sones.GraphDS.Services.RemoteAPIService.EdgeTypeService;
using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.VertexInstanceService;
using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.EdgeInstanceService;
-using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MonoMEX;
+using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.MEX;
using sones.GraphDS.Services.RemoteAPIService.ServiceContracts.StreamedService;
using System.Xml;
using System.ServiceModel.Channels;
@@ -86,7 +86,7 @@ public class sonesRPCServer
public Uri URI { get; private set; }
/// <summary>
- /// The URI of the metadata exchange service
+ /// The complete URI of the mex service
/// </summary>
public Uri MexUri { get; private set; }
@@ -95,6 +95,11 @@ public class sonesRPCServer
/// </summary>
private ServiceHost _ServiceHost;
+ /// <summary>
+ /// The Metadata Exchange Service Host
+ /// </summary>
+ private ServiceHost _MexServiceHost;
+
#endregion
#region C'tor
@@ -106,17 +111,18 @@ public sonesRPCServer(IGraphDS myGraphDS, IPAddress myIPAdress, ushort myPort, S
this.ListeningIPAdress = myIPAdress;
this.ListeningPort = myPort;
this.IsSingleFile = myIsSingleFile;
- String CompleteUri = (myIsSecure == true ? "https://" : "http://") + myIPAdress.ToString() + ":" + myPort + "/" + myURI;
- this.URI = new Uri(CompleteUri);
+ this.URI = new Uri((myIsSecure == true ? "https://" : "http://") + myIPAdress.ToString() + ":" + myPort + "/" + myURI);
+ this.MexUri = new Uri("http://" + myIPAdress.ToString() + ":" + (myPort + 1) + "/" + myURI);
if (!this.URI.IsWellFormedOriginalString())
throw new Exception("The URI Pattern is not well formed!");
InitializeServer();
if (myAutoStart)
- _ServiceHost.Open();
-
+ {
+ StartServiceHost();
+ }
}
#endregion
@@ -259,33 +265,33 @@ private void InitializeServer()
* - (server side) Mono does not yet support wsdl generation
* - Java Stub generation using Axis causes the server to hang up
* - Some importers may not support multiple markup files
+ *
+ * Therefore, a static wsdl file is provided to the client.
*/
- ServiceMetadataBehavior metadataBehavior = new ServiceMetadataBehavior();
- Binding mexBinding;
- if (IsSecure == true)
- {
-
- mexBinding = MetadataExchangeBindings.CreateMexHttpsBinding();
- metadataBehavior.HttpsGetEnabled = true;
- }
- else
- {
- mexBinding = MetadataExchangeBindings.CreateMexHttpBinding();
- metadataBehavior.HttpGetEnabled = true;
- }
-
- _ServiceHost.Description.Behaviors.Add(metadataBehavior);
- mexBinding.Namespace = Namespace;
- _ServiceHost.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex");
-
- //var mexEndpoint = new ServiceEndpoint(new ContractDescription("IMetadataExchange", "System.ServiceModel.Description"), mexBinding, new EndpointAddress(this.URI.ToString() + "/mex"));
- //mexEndpoint.Name = "MexEndpoint";
- //if (IsSingleFile == true)
+ _MexServiceHost = new ServiceHost(typeof(MonoMEX), MexUri);
+ _MexServiceHost.Description.Namespace = Namespace;
+ Binding MexBinding = new WebHttpBinding();
+ MexBinding.Namespace = Namespace;
+
+ ContractDescription MexContract = ContractDescription.GetContract(typeof(IMonoMEX));
+ ServiceEndpoint MexService = new ServiceEndpoint(MexContract, MexBinding, new EndpointAddress(MexUri.ToString()));
+ _MexServiceHost.AddServiceEndpoint(MexService);
+ _MexServiceHost.Description.Endpoints[0].Behaviors.Add(new System.ServiceModel.Description.WebHttpBehavior());
+
+
+ //// auto generation
+ //ServiceMetadataBehavior metadataBehavior = new ServiceMetadataBehavior();
+ //metadataBehavior.HttpGetEnabled = true;
+ //Binding mexBinding = MetadataExchangeBindings.CreateMexHttpBinding();
+ //mexBinding.Namespace = Namespace;
+ //_ServiceHost.Description.Behaviors.Add(metadataBehavior);
+ //ServiceEndpoint mexEndpoint = _ServiceHost.AddServiceEndpoint(ServiceMetadataBehavior.MexContractName, mexBinding, "mex");
+ //foreach (ServiceEndpoint endpoint in _ServiceHost.Description.Endpoints)
//{
- // mexEndpoint.Behaviors.Add(new WsdlExtensions(new WsdlExtensionsConfig() { SingleFile = true }));
- //}
- //_ServiceHost.AddServiceEndpoint(mexEndpoint);
+ // //export just one file
+ // endpoint.Behaviors.Add(new WsdlExtensions(new WsdlExtensionsConfig() { SingleFile = true }));
+ //}
#endregion
}
@@ -298,8 +304,24 @@ public void StartServiceHost()
{
if(!IsRunning)
{
- _ServiceHost.Open();
- IsRunning = true;
+ try
+ {
+ _ServiceHost.Open();
+ _MexServiceHost.Open();
+ IsRunning = true;
+ }
+ catch (Exception e)
+ {
+ if (_ServiceHost != null)
+ {
+ _ServiceHost.Close();
+ }
+ if (_MexServiceHost != null)
+ {
+ _MexServiceHost.Close();
+ }
+ throw e;
+ }
}
}
@@ -308,6 +330,7 @@ public void StopServiceHost()
if (IsRunning)
{
_ServiceHost.Close();
+ _MexServiceHost.Close();
IsRunning = false;
}
}

0 comments on commit ad3a818

Please sign in to comment.
Something went wrong with that request. Please try again.