I want to recive RemoteObject from my service. Everything works fine but my code looks like this:
<mx:AMFChannel id="myamf" uri="messagebroker/amf"/>
<mx:ChannelSet id="channelSet" channels="{[myamf]}"/>
<mx:RemoteObject id="ro" channelSet="{channelSet}" destination="pServ" result="resultHandler(event);" fault="faultHandler(event);"/>
is there a way to avoid hard typing channel uri in my .mxml file?
i tried with default channels in blazeds xml but without succes.
thats are parts of my configuration:
spring appContext.xml
<context:component-scan base-package="org.flex.test.services"/>
<flex:message-broker>
<flex:remoting-service default-channels="my-amf"/>
</flex:message-broker>
<flex:remoting-destination ref="personService" destination-id="pServ"/>
flex services-config.xml
<services>
<default-channels>
<channel ref="my-amf"/>
</default-channels>
<service id="remoting-service" class="flex.messaging.services.RemotingService">
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
</service>
</services>
<channels >
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
Im running flex app from root of aplication file - main.html.
Thank you for answers!
The default channel will work, but you need to add a reference to the services.xml as a compiler argument so that the compiler knows what the default is. Something like this should do the trick...
-services {Your base directory}\src\main\webapp\WEB-INF\flex\services-config.xml
Related
Using Visual Studio 2013 Premium.
Goal: I have multiple WCF services defined in a web.config. To keep the web.config file readable and make adding services simpler, I want to use VS2013's XML transforms to add some boilerplate elements to each service definition for my dev/production environments.
Problem: I have multiple <service> tags, but only the first one is transformed properly.
Here's a simplified version of my Web.Config with two services defined:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<services>
<service name="AppName.AccountManagerService">
<endpoint address="AccountManagerService" binding="netTcpBinding"
bindingConfiguration="" contract="Shared.Contracts.IAccountManagerService" />
</service>
<service name="AppName.TicketManagerService">
<endpoint address="TicketManagerService" binding="netTcpBinding"
bindingConfiguration="" contract="Shared.Contracts.ITicketManagerService" />
</service>
</services>
</configuration>
I want to create a Metadata exchange endpoint and do some other things (not shown) to each <service> tag.
Here's a simplified Web.Debug.Config showing only the MetadataExchange endpoint:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.serviceModel>
<services>
<service xdt:Locator="XPath(/configuration/system.serviceModel/services/service)">
<endpoint kind="mexEndpoint"
address="mex"
xdt:Transform="Insert()"
/>
</service>
</services>
</system.serviceModel>
</configuration>
I get this:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<services>
<service name="AppName.AccountManagerService">
<endpoint address="AccountManagerService" binding="netTcpBinding"
bindingConfiguration="" contract="Shared.Contracts.IAccountManagerService" />
<!-- Yay! -->
<endpoint kind="mexEndpoint"
address="mex"
/>
</service>
<service name="AppName.TicketManagerService">
<endpoint address="TicketManagerService" binding="netTcpBinding"
bindingConfiguration="" contract="Shared.Contracts.ITicketManagerService" />
<!-- Hey, where's the endpoint tag for this one? -->
</service>
</services>
</configuration>
I've tried these variations on the XPath argument in the xdt:Locator attribute of the :
1. /configuration/system.serviceModel/services/service
2. /configuration/system.serviceModel/services//service
3. //service
All of which transform only the 1st <service> section.
I've tried putting the xdt:Locator attribute on the <endpoint> tag, etc. to no avail.
I have multiple XPath visualizers and tools, and all of them match both <service> tags when used with XPath #1 above. Also, this error happens in "Preview Transform" and the web deployment tool preview.
What am I doing wrong?
(My workaround, at this point, is to include the Mex endpoint and the rest of the debugging cruft in my original Web.Config, and then remove it with "RemoveAll()", but that makes my Web.Config really cluttered and hard to read.)
I recently ran into this issue, and it turns out it isn't supported.
My work around was adding a custom transform, and using that instead of Insert. The issue with their implementation is that the default Insert only modifies the first value (even though the XPath expression does retrieve a list).
The XDT source can be found here: http://xdt.codeplex.com/
The article I ran across that got me in the right direction: http://blog.appharbor.com/2012/07/27/custom-web-config-transforms-and-merges
What I did is add a new class to their source, and was able to achieve exactly what you are looking for.
internal class InsertMultiple : Transform
{
public InsertMultiple()
{
//this is the line that allows it to apply the transform for all nodes
//that were located with your XPath expression.
ApplyTransformToAllTargetNodes = true;
}
protected override void Apply()
{
CommonErrors.ExpectNoArguments(Log, TransformNameShort, ArgumentString);
TargetNode.AppendChild(TransformNode);
Log.LogMessage(MessageType.Verbose, SR.XMLTRANSFORMATION_TransformMessageInsert, TransformNode.Name);
}
}
I am trying to build an eventlistener for my project and followed the instruction of this guide: How to register eventlisteners I edited my services.xml like in the tutorial , but i get this error message, when i want to test it:
InvalidArgumentException: There is no extension able to load the configuration for "doctrine:config" (in /var/www/symfony/src/Acme/AppBundle/DependencyInjection/../Resources/config/services.xml). Looked for namespace "http://symfony.com/schema/dic/doctrine", found none
My services.xml :
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<doctrine:config>
<doctrine:dbal default-connection="default">
<doctrine:connection driver="pdo_sqlite" memory="true" />
</doctrine:dbal>
</doctrine:config>
<services>
<service id="my.listener" class="Acme\AppBundle\EventListener\Confirmer">
<tag name="doctrine.event_listener" event="preUpdate" />
</service>
</services>
</container>
Where is the problem?
You don't need the doctrine configuration in your service config.
The connection driver is being configured inside app/config/config.yml.
The listener configuration looks good though - just remove the doctrine:config stuff.
Have a look at the doctrine configuration reference.
Symfony will automatically use the default connection for your listener/subscriber if you don't specify one using the connectionoption. The documentation is a bit confusing here but the doctrine connection is just there to show how to use a different connection.
I have the following configured in my <system.serviceModel> tag of my web.config file:
<system.serviceModel>
<bindings/>
<client/>
<behaviors>
<serviceBehaviors>
<behavior name="serviceTypeBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
<services>
<service behaviorConfiguration="serviceTypeBehaviors" name="AcpService.MainFrameData">
<endpoint address="" binding="basicHttpBinding" contract="AcpService.IMainFrameService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
The XML of my service is this:
<%# ServiceHost Language="C#" Debug="true" Service="AcpService.MainFrameData" CodeBehind="MainFrameWoData.svc.cs" %>
My application is running in the Default Web Site's Application Pool with Enable 32-Bit Applications set to True (because the service uses some old data accessing libraries).
When I run it, I get this error:
Server Error in '/mainframe' Application.
The type 'AcpService.MainFrameData', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
Exception Details: System.InvalidOperationException: The type 'AcpService.MainFrameData', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
I almost modified my <serviceHostingEnvironment> tag to include the <serviceActions> parameters, but I don't really understand how to do that.
This is how far I got:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add factory="System.ServiceModel.Activation.ServiceHostFactory"
relativeAddress="~/mainframe/MainFrameWoData.svc"
service="AcpService.MainFrameData" />
</serviceActivations>
</serviceHostingEnvironment>
I'm not sure if I am doing this correctly, and I have no idea what to insert for the service= parameter. The info on MSDN seems useless.
This project originally had a different name, but I am having to add features to the service. I do not want to edit the active service, because doing so would mean all the employees trying to access the data on our internal network would be getting that error right now, so the service was copied to a new project, and it is being published to a new location on our server. My best guess is there is something in the web.config file (or ???) that does not match up to something the project itself.
Could someone give me some help with this?
Looks like my project wanted MainFrameService instead of MainFrameData.
I started to delete this post, but... who knows? Perhaps someone else can get some use out of it.
I would like to have a variable defined in my web.config that I can use in multiple places within my web.config file (and other config files). It's probably easier to explain by example ...
web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="AuthServiceEndPoint" value="any_old_name_i_like"/>
</appSettings>
<system.web>
...
<system.serviceModel>
<client>
<endpoint
address="net.tcp://localhost/AuthService"
binding="netTcpBinding"
contract="MyServices.Contracts.IAuthService"
name="#{AppSettings.AuthServiceEndPoint}"
bindingConfiguration="netTcpBindingConfig"
/>
</client>
</system.serviceModel>
</configuration>
windsor.config
<?xml version="1.0" encoding="utf-8" ?>
<castle>
<components>
...
<component
id="AuthProvider"
service="MyServices.Client.IAuthProvider, MyServices.Client"
type="MyServices.Client.AuthProvider, MyServices.Client"
lifestyle="transient">
<parameters>
<endpoint>#{AppSettings.AuthServiceEndPoint}</endpoint>
</parameters>
</component>
</components>
</castle>
Is this possible?
Edit (a bit more information)
I already have the ability to access the AppSettings from my windsor.config file (which is actually processed by castle windsor and a custom XmlInterpreter.
The real question is can I do this in my web.config?
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="AuthServiceEndPoint" value="any_old_name_i_like"/>
</appSettings>
<system.web>
...
<system.serviceModel>
<client>
<endpoint
address="net.tcp://localhost/AuthService"
binding="netTcpBinding"
contract="MyServices.Contracts.IAuthService"
name="#{AppSettings.AuthServiceEndPoint}"
bindingConfiguration="netTcpBindingConfig"
/>
</client>
</system.serviceModel>
</configuration>
ie - access variable in my <appSettings> from other parts of my web.config file.
Off the top of my head, I wonder if you might be able to do this with T4? I'm thinking that perhaps you could define a template which parses Web-Template.config and outputs Web.config? Of course, this only works for a single file.
You can use NAnt or MSBuild for this. You do need separate configuration files for both, but when you build your project they can automatically do transformations on your Web.config and other configuration files.
Not that I can think of. You could do your configuration in C# in global.asax.cs instead of the xml file.
Alternatively, have your web.config edited by your build process to replace all these values. FinalBuilder has a neato "Edit XML File" action that uses XPath quite well to do this, and FinalBuilder does have variables. Problem solved. This is how I do my builds at work.
Here I go answering my own question again :-S
I solved this by writing a NetTcpServiceLocator ...
public interface INetTcpServiceLocator
{
EndpointAddress GetAddress(Type serviceType);
}
... along with a custom config section handler which also implements the above interface and reads in the following config section ...
<services>
<service contract="My.Services.TestService.Contracts.ITestService" address="net.tcp://localhost/TestService" />
</services>
Then I created a proxy for each service ...
public class TestServiceProxy : ITestService
{
public SomeInformation GetSomeInformation(SomeParams #params)
{
using (var factory = new NetTcpServiceFactory<ITestService>())
{
var service = factory.Service;
return service.GetSomeInformation(#params);
}
}
}
My Controller has a dependency on a Service, which has a dependancy on ITestService. All this is glued together with Castle Windsor and by using property dependency injection.
So, my controller calls it's Service, which in turn calls the ITestService (in this case a proxy, which gets it's endpoint from the custom section handler).
The custom section handler (which is also the INetTcpServiceLocator) has a windsor lifestyle of "perWebRequest", so it gets called by the framework and web.config is read into an array in memory. When the service proxy is called, it then just pulls the relevant endpoint based on the contract type.
It's all driven by the type of the contract, so there is no need to have any variables in web.config anymore.
I've gone for a code based solution, as I don't use a build process locally, only when I submit my code to subversion does the build process kick in on our build server.
Yesterday I spent half of day trying to force Flex Remoting to use HTTPS with no success.
Today I tried to connect to other domain.
I changed url of endpoint, but it looks like flex just ignores my changes.
I am sure that an old url doesn't exist in any file in src directory,
I even renamed services-config.xml to services-config2.xml, cleaned and rebuilded project many times, even made a release build, but it still connects to the same domain.
I have tested flex application in localhost and in the same domain, that has AMF services, but it works in the same way.
My services-config.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">
<destination id="amfphp">
<channels>
<channel ref="my-amfphp-secure"/>
<channel ref="my-amfphp"/>
</channels>
<properties>
<source>*</source>
</properties>
</destination>
</service>
</services>
<channels>
<channel-definition id="my-amfphp-secure" class="mx.messaging.channels.SecureAMFChannel">
<endpoint uri="https://xxx.dev.company.com:443/AMF" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
<properties>
<polling-enabled>false</polling-enabled>
<serialization>
<instantiate-types>false</instantiate-types>
<log-property-errors>true</log-property-errors>
</serialization>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition>
<channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel" >
<endpoint uri="http://xxx.dev.company.com/AMF" class="flex.messaging.endpoints.AMFEndpoint" />
<properties>
<polling-enabled>false</polling-enabled>
<serialization>
<instantiate-types>false</instantiate-types>
<log-property-errors>true</log-property-errors>
</serialization>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition>
</channels>
</services-config>
RemoteObject definition in mxml:
<mx:RemoteObject id="Agentrpc" destination="amfphp" source="Agentrpc" showBusyCursor="true">
<mx:method name="getAgentID" result="getAgentID_resultHandler(event)" fault="faultHandler(event)"/>
</mx:RemoteObject>
I'm using Flex 3.
Edit: I took a look at generated/ dir and I see that FlexInit files (like MainModule_FlexInit-generated.as) contains code:
ServerConfig.xml =
<services>
<service id="amfphp-flashremoting-service">
<destination id="amfphp">
<channels>
<channel ref="my-amfphp-secure"/>
<channel ref="my-amfphp"/>
</channels>
</destination>
</service>
<channels>
<channel id="my-amfphp-secure" type="mx.messaging.channels.SecureAMFChannel">
<endpoint uri="https://gintautas.dev.company.com:443/AMF"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel>
<channel id="my-amfphp" type="mx.messaging.channels.AMFChannel">
<endpoint uri="http://gintautas.dev.company.com/AMF"/>
<properties>
<polling-enabled>false</polling-enabled>
</properties>
</channel>
</channels>
</services>;
That's correct, but application doesn't make requests to gintautas.dev.company.com
Edit 2: I installed Flash Builder 4 and tried to compile using 3.5 and 4.0(in compatibility mode) compilers, but both has the same problem :(
Can you try to clear your browser cache ? The content of the services.xml is injected into the SWF at compile time.
you can check what is being compiled into flex from the *-config.XML files with the following:
trace( ServerConfig.XML );
Also, if using WTP with tomcat, check if server is using the actual installation of tomcat, or a temp eclipse folder to run. that can sometimes cause mix ups.
You must "clean project" in Flex Builder when you change services-config.xml