While sending a service request (PHP Service) from Flex application, it is executing multiple service request to server. How can we avoid first call? - apache-flex

While sending a service request (PHP Service) from Adobe Flex application , it is calling multiple service request to server. How can we avoid first call ?
Please help me to resolve it.
First one is a blank service with operation => 5.
We can show blank service call via firebug (Browser -> Developer tool)
Sample Flex Code :
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:RemoteObject id="CustomerRo" destination="customerService" endpoint="<SERVER URL>"
showBusyCursor="false" source="customerService" concurrency="single" >
<s:method name="customerLogin" fault=""
result="method1_resultHandler(event)" />
</s:RemoteObject>
</fx:Declarations>
<s:Button click="button1_clickHandler(event)" label="Send" />

I believe the 5 is part of the AMF protocol and signals that a command operation is the next operation that should be expected by the server.

We need to do the following changes in flex application for avoid duplicate call from every request
    Add 'services-config.xml" to the application folder. (Ref : https://gist.github.com/hui/268372 )
    Add  configuration file path to Flex compiler, (Project->Properties->Flex Compiler)
       Example :  -locale en_US -services "C:\Location/services-config.xml"
    Change this attribute in code base of each modules
        
From : < s:RemoteObject id="CustomerRo" destination="customerService" endpoint="< SERVER URL >" showBusyCursor="false" source="customerService" concurrency="single" >
        
To : < s:RemoteObject id="CustomerRo" destination="amfora" showBusyCursor="false" source="customerService" concurrency="single" >
[Note : Destination should be equal to < destination id="amfora" > in 'services-config.xml" ]

Related

Adding two seperate firebase projects for a single app

I want to implement e-commerce apps on IOS and Android. I can divide the apps into two parts less secured, more secured. I can say more secure is a case of accepting payments in the app.So for this purpose, I want to have separate login systems for entering into the app and making payments.I am using Firebase Authentication and in that Password Authentication.So at the start of the project if we want to use Firebase(for Authentication, Database)we need to add google-services.json for Android App and GoogleService-Info.plist for IOS App. But now I want to add two firebase projects for a single app. How is it possible?
Use multiple firebase projects in single application
Simply can access multiple projects through FirebaseApp configure.
Configuration
let secondaryOptions = FirebaseOptions(googleAppID: "your google app id",
                                           gcmSenderID: "your gcm id")
    secondaryOptions.apiKey = "your api key"
    secondaryOptions.projectID = "your projectid"
   
    secondaryOptions.bundleID = "your bundle id"
    secondaryOptions.databaseURL = "https://yourproject.firebaseio.com"
    secondaryOptions.storageBucket = "yourproject.appspot.com"
    secondaryOptions.androidClientID = "yourproject.apps.googleusercontent.com"
    secondaryOptions.deepLinkURLScheme = "myapp://"
    secondaryOptions.storageBucket = "yourprojectId.appspot.com"
    secondaryOptions.appGroupID = nil
FirebaseApp.configure(name: "secondary", options: secondaryOptions)
Usage
guard let secondary = FirebaseApp.app(name: "secondary")
else { assert(false, "Could not retrieve secondary app") }
let secondaryDb = Database.database(app: secondary)
in your firebase. open up a project and click on 'add another project'.
and then select app for IOS or Android. You are done.

Confused with load-on-startup value

When we mention any servlet as loadOnStartup in web.xml then its init method is called at applicaton startup.
<web-app xmlns="http://java.sun.com/xml/ns/javaee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd     version="3.0">       
<servlet>         
<servlet-name>SimpleServlet</servlet-name>         
<servlet-class>app01c.SimpleServlet</servlet-class>         
<load-on-startup>10</load-on-startup>     
</servlet>      
 <servlet-mapping>         
<servlet-name>SimpleServlet</servlet-name>         
<url-pattern>/simple</url-pattern>     
</servlet-mapping>        
</web-app>
<load-on-startup>10</load-on-startup>
here, what does it mean for the value 10? if i change it to
5, what will happen? having less value will make it to load earlier? if so, if it is 0, is it the earliest? i am little confused with as i came across some googling that positive value in load-on-startup, make it to load at start up.
Does this positive is greater than than 0? Does 0 value is same as nothing in load-on-startup?
0 is the highest priority.
If you have only one servlet you can not see the difference
ServletName load-on-start-up_value
Servlet1 4(3)
Servlet2 6(4)
Servlet3 3(2)
Servlet4 2(1)
Servlet4 object will be created first then Servlet3 object will be created and then Servlet1 and Servlet2 objects will be created.
If you give -1 it will be ignored
By default, servlet object is created when you make the first request to servlet, but if you want to create the servlet object at the load time(or start up time), then you can provide <load-on-startup></load-on-startup> value in web.xml.
<load-on-startup></load-on-startup> is servlet wise. If there are 2 servlets in your application so you need to provide <load-on-startup></load-on-startup> value for each servlet.
<load-on-startup></load-on-startup> value either 0 or any positive integer. If you are putting <load-on-startup>10</load-on-startup> value 10, and you have only single servlet then it will not affect any thing, but you have more then 1 servlet then 0 value is highest priority and then so on.

Parsley autowiring not working

I'm starting with Parsley and cannot manage to make the autowire working. My configuration is based on flex 4.5 and parsley 3.0.0.
My application contains the folowing bootrap :
<fx:Declarations>
<parsley:ViewSettings autowireComponents="true"/>
<parsley:ContextBuilder config="{SimulateurConfig}" />
<s:TraceTarget
includeCategory="true"
includeLevel="true"
includeTime="true"
level="{LogEventLevel.DEBUG}"
>
<s:filters>
<fx:String>org.spicefactory.parsley.*</fx:String>
</s:filters>
</s:TraceTarget>
</fx:Declarations>
The configuration is quite simple :
<fx:Declarations>
<View type="com.coach.ui.PanelAFinancer"/>
<Object type="com.coach.domain.AFinancer" />
</fx:Declarations>
And my Panel contains :
<fx:Script><![CDATA[
import com.coach.domain.AFinancer;
[Bindable] [Inject]
public var model:AFinancer;
]]></fx:Script>
<s:Label text="Model injected? { model != null }"/>
I think I did everything right but the model is not injected in my view. The trace indicates :
[trace] 12:49:12.186 [INFO] org.spicefactory.parsley.core.state.manager.impl.DefaultGlobalDomainManager Using new ApplicationDomain for key [object _Flex_simulateur_mx_managers_SystemManager]
[trace] 12:49:12.218 [INFO] org.spicefactory.parsley.core.view.impl.DefaultViewManager Add view root: Flex_simulateur0/Flex_simulateur
[trace] 12:49:12.218 [INFO] org.spicefactory.parsley.core.bootstrap.impl.DefaultBootstrapManager Creating Context [Context(FlexConfig{SimulateurConfig})] without parent
[trace] 12:49:12.296 [INFO] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Configure managed object with [ObjectDefinition(type = com.coach.domain::AFinancer, id = _SimulateurConfig_MxmlRootObjectTag1)] and 0 processor(s)
No sign of view processing.
If I add the «manual configuration» in the panel :
<fx:Declarations>
<sf:Configure/>
</fx:Declarations>
The injection works:
[trace] 12:56:04.983 [INFO] org.spicefactory.parsley.core.state.manager.impl.DefaultGlobalDomainManager Using new ApplicationDomain for key [object _Flex_simulateur_mx_managers_SystemManager]
[trace] 12:56:05.015 [INFO] org.spicefactory.parsley.core.view.impl.DefaultViewManager Add view root: Flex_simulateur0/Flex_simulateur
[trace] 12:56:05.030 [INFO] org.spicefactory.parsley.core.bootstrap.impl.DefaultBootstrapManager Creating Context [Context(FlexConfig{SimulateurConfig})] without parent
[trace] 12:56:05.124 [INFO] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Configure managed object with [ObjectDefinition(type = com.coach.domain::AFinancer, id = _SimulateurConfig_MxmlRootObjectTag1)] and 0 processor(s)
[trace] 12:56:05.140 [DEBUG] org.spicefactory.parsley.core.view.handler.ViewConfigurationHandler Process view 'Flex_simulateur0.ApplicationSkin3._ApplicationSkin_Group1.contentGroup.viewRoot.PanelAFinancer7' with [Context(FlexConfig{SimulateurConfig})]
[trace] 12:56:05.155 [INFO] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Configure managed object with [ObjectDefinition(type = com.coach.ui::PanelAFinancer, id = _SimulateurConfig_MxmlViewTag1)] and 1 processor(s)
[trace] 12:56:05.155 [DEBUG] org.spicefactory.parsley.core.lifecycle.impl.DefaultManagedObjectHandler Applying [Property(name=[Property model in class com.coach.ui::PanelAFinancer],value={ImplicitTypeReference(type=undefined)})] to managed object with [ObjectDefinition(type = com.coach.ui::PanelAFinancer, id = _SimulateurConfig_MxmlViewTag1)]
[trace] 12:56:05.171 [DEBUG] org.spicefactory.parsley.core.view.processor.DefaultViewProcessor Add view 'Flex_simulateur0.ApplicationSkin3._ApplicationSkin_Group1.contentGroup.viewRoot.PanelAFinancer7' to [Context(FlexConfig{SimulateurConfig})]
The workaround is quite heavy as it requires adding in all my views the proprietary tags.
Any idea of what is wrong with my configuration?
I would recommend that you use another solution. When you configure (or wire) a view, Parsley needs to reflect the class and iterate through all properties to find the injection points. This is costly and time consuming. It might be fine for only a few wired views, but normally that is not the case since if you're using Flex and Parsley, there's a good chance you'll have a lot of views.
The better approach is to create all models, presenters, services, etc. in the parsley config, excluding all Views. In the views, you'd only have to use the FastInject tag as such:
<fx:Declarations>
<spicefactory:FastInject property="model" type="{AFinancer}" />
</fx:Declarations>
<fx:Script><![CDATA[
import com.coach.domain.AFinancer;
[Bindable]
public var model:AFinancer;
]]></fx:Script>
This is a much better approach since reflection isn't needed. The only "issue" is that you cannot use Parsley metadata in your views, which is better for separating business concerns from the view. This also helps you reuse presenters throughout your application and help out with testing of said presenters.

import users to ASP.NET membership from a file

I have a site using ASP.NET membership. I also have an excel file with about 60 user records. How can I import the records into the membership database, without having to type all 60 into the ASP.NET Web Site Administration Tool.
Thank you
foreach (record in recordset) {
    if (!(Roles.RoleExists(record["Role"])) {
        Roles.CreateRole(record["Role"]);
    }
   
    if (Membership.GetUser(record["Username"]) == null) {
        System.Web.Security.MembershipCreateStatus status;
        Membership.CreateUser(record["Username"], record["Password"], record["Email"], record["RSecurityQuestion"], record["SecurityAnswer"], true, status);
        if (status == System.Web.Security.MembershipCreateStatus.Success) {
            Roles.AddUserToRole(record["Username"], record["Role"]);
        }
    }
}
I can't recall the code to create a recordset from an Excel file off the top of my head.
EDIT: Here is a good post on how to read/write excel files with ADO.NET
Here's three options for you
There may be an import data option in SQL Server Management Studio, you can use this (I just checked in SQL Server Express and it wasn't there but I'm certain it exists in the full version of Management Studio - can't check at the moment).
Use SSIS if you have it
You can do it old school and use Excel to build up a SQL string with references to the cells. Do this for the first row and then copy down. Copy all the statements into a query window and execute!
Choice 1
If you're lucky, Excel has a way to export the rows directly to your database (this depends on which Database you're using)
Choice 2
Write a program that iterates over each row in the excel table and inserts it manually into your database (again, process depends on which one)

Does anyone know if the crossdomain policy file at salesforce.com has changed?

Suddenly my Flex Apps can no longer connect to salesforce.com via its API, I am getting a security sandbox violation. Login credentials are correct, I have tried them via a different means, and I have obfuscated them below.
This was working fine earlier today and I have not been coding since then.
Anyone else come across this or know what's going on?
Here is the exception returned to my app
Method name is: login
'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer connected.
'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer sending message 'B89E5879-D7F7-E91E-2082-BBEE231054DD'
'direct_http_channel' channel sending message:
(mx.messaging.messages::HTTPRequestMessage)#0
body = "<se:Envelope xmlns:se="http://schemas.xmlsoap.org/soap/envelope/"><se:Header xmlns:sfns="urn:partner.soap.sforce.com"/><se:Body><login xmlns="urn:partner.soap.sforce.com" xmlns:ns1="sobject.partner.soap.sforce.com"><username>simon.palmer#***.com</username><password>***</password></login></se:Body></se:Envelope>"
clientId = (null)
contentType = "text/xml; charset=UTF-8"
destination = "DefaultHTTPS"
headers = (Object)#1
httpHeaders = (Object)#2
Accept = "text/xml"
SOAPAction = """"
X-Salesforce-No-500-SC = "true"
messageId = "B89E5879-D7F7-E91E-2082-BBEE231054DD"
method = "POST"
recordHeaders = false
timestamp = 0
timeToLive = 0
url = "https://www.salesforce.com/services/Soap/u/11.0"
Method name is: login
*** Security Sandbox Violation ***
Connection to https://www.salesforce.com/services/Soap/u/11.0 halted - not permitted from https://localhost/pm_server/pm/pm-debug.swf
'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer acknowledge of 'B89E5879-D7F7-E91E-2082-BBEE231054DD'.
'A997F86A-36E9-DDDC-EC6B-BBEE23101466' producer fault for 'B89E5879-D7F7-E91E-2082-BBEE231054DD'.
Comunication Error : Channel.Security.Error : Security error accessing url : Destination: DefaultHTTPS
Error: Request for resource at https://www.salesforce.com/services/Soap/u/11.0 by requestor from https://localhost/pm_server/pm/pm-debug.swf is denied due to lack of policy file permissions.
You have to make sure to load the policy from the /services tree, the default policy at the root won't help you. You need to load this policy https://www.salesforce.com/services/crossdomain.xml
The solution to this problem was to set the server protocol and url as follows:
apex = new Connection();
apex.serverUrl = "https://na3.salesforce.com/services/Soap/u/14.0";
apex.protocol = "https";
However, this seems to create a secondary issue of users being locked out, so the issue of non-connectivity remains.
Update: salesforce.com have acknowledged a bug. See my other related post.
Did you recently upgrade to flash player 10? Flash player 10 changes the way policy files work to some degree, and the crossdomain.xml file needs to be updated to address this. In short, Salesforce.com probably isn't prepared for users upgrading to Flash Player 10 yet.
I resolve this issue accessing to the Flash Player Configuration Panel(I just recommend it in a development environment), in the "Global Security" tab, select Always Allow.
Regards.
I am uploading a file from flex to Google docs. Everything is working in the local file however, when we upload the SWF file as S-controls in Salesforce (sandbox), an error appears upon connecting to Google. Please see error below:
Error:[FaultEvent fault=[RPC Fault faultString="Security error accessing url"
faultCode="Channel.Security.Error" faultDetail="Destination: DefaultHTTPS"]
messageId="1F812836-1318-B845-AC01-F51AB1D11518" type="fault" bubbles=false
cancelable=true eventPhase=2]
We tried the following solutions below but nothing seems to work:
FLEX:
- Add the crossdomain.xml in the bin-debug folder: below is the content of the cross domain policy.
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" secure="false" />
<allow-http-request-headers-from domain="*" headers="*" secure="false" />
</cross-domain-policy>
Used flash.system.security.allowinsecuredomain/allowdomain(“*”) in the initialization.
Also tried in the connection.protocol set to http
Salesforce:
Disabled the protocol security in the remote site settings
o Setup -> Administration Setup -> Security Controls -> Remote Site Settings
 URL: http://www.google.com.ph
There’s no problem in connection to Salesforce but upon initialization of the uploading page the security error will appear specifically in the onErrorFault function. Below are code snippets:
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="534" height="462" verticalScrollPolicy="off" horizontalScrollPolicy="off"
creationComplete="init()" showCloseButton="true" close="{this.closeWindow(event)}" roundedBottomCorners="true">
<mx:Script>
<![CDATA[
private function init():void{
Security.allowInsecureDomain("*");
//<salesforce:Connection id="apex" sendRequest="sendRequestListener(event)" serverUrl="http://www.salesforce.com/services/Soap/u/10.0" protocol="http"/>
RESTProxyTest();
send_data();
arrAddedFiles = new Array();
this.uploadGrid.dataProvider= this.acFiles;
this.title = "Attachment: "+this.selectedTimeSheetDetail.Project.label;
}
public function RESTProxyTest():void
{
_conn = new NetConnection();
_conn.addEventListener(AsyncErrorEvent.ASYNC_ERROR, doAsyncError);
_conn.addEventListener(IOErrorEvent.IO_ERROR, doIOError);
_conn.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doSecurityError);
_conn.addEventListener(NetStatusEvent.NET_STATUS, doNetStatus);
_conn.objectEncoding = ObjectEncoding.AMF3;
_conn.connect(_url);
_responder = new Responder(onResult, onFault);
}
private function send_data():void {
userRequest.url = getLoginURL();
userRequest.addEventListener(ResultEvent.RESULT, httpResult);
userRequest.addEventListener(FaultEvent.FAULT, onErrorFault);
userRequest.send();
}
private function onErrorFault(obj:FaultEvent):void
{
Alert.show("Error:"+obj.toString());
}
private function httpResult(obj:ResultEvent):void
{
trace(obj.toString());
var result:String = obj.result as String;
var pos:int = result.lastIndexOf("Auth=");
var auth:String = result.substr(pos + 5);
txtAuth.text = StringUtil.trim(auth);
placeCall();
}
protected function placeCall():void
{
trace("placeCall");
var headers:Array = ["Authorization: " + "GoogleLogin auth=" + StringUtil.trim(txtAuth.text)];
var postVars:Array = [];
var uri:String = "http://docs.google.com/feeds/documents/private/full?showfolders=true";
_conn.call("RESTProxy.request", _responder, uri, "get", new Array(), postVars, headers);
}
private function getLoginURL():String
{
var url:String = 'https://www.google.com/accounts/ClientLogin?accountType=HOSTED_OR_GOOGLE&' +
'Email=' + this.session.config.gmail + '&' +
'Passwd=' + this.session.config.password + '&service=writely';
return url;
}
]]>
</mx:Script>
<mx:HTTPService id="userRequest" useProxy="false" method="POST" contentType="application/x-www-form-urlencoded" showBusyCursor="true"/>

Resources