Does AllJoyn Studio Extension support generation of methods with arguments? - alljoyn

I've tried to create a simple project using AllJoyn to expose an interface to my Garage Door via a Raspberry Pi 2 running Windows 10 IoT.
The relevant Introspection XML file is as follows:
<node xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:noNamespaceSchemaLocation="https://allseenalliance.org/schemas/introspect.xsd">
<interface name="com.hastarin.GarageDoor">
<!--<annotation name="org.alljoyn.Bus.Secure" value="true" />-->
<description language="en">Interface for controlling a garage door.</description>
<property name="IsOpen" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<description language="en">Is TRUE if the door is open.</description>
</property>
<property name="IsPartiallyOpen" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="true"/>
<description language="en">Is TRUE if the door is only partially open for air flow.</description>
</property>
<method name="Open">
<description language="en">Opens the door if it's closed.</description>
<argument name="partialOpen" type="b" direction="in">
<description language="en">
If TRUE, the door will only be partially opened to allow air flow.
If FALSE, the door will be fully opened.
</description>
</argument>
</method>
<method name="Close">
<description language="en">Close the door if it's open.</description>
</method>
<method name="PushButton">
<description language="en">Will trigger the push button on the garage door.</description>
</method>
</interface>
</node>
Unfortunately the generated service interface does not include the argument for the Open method.
public interface IGarageDoorService
{
IAsyncOperation<GarageDoorOpenResult> OpenAsync([In] AllJoynMessageInfo info);
IAsyncOperation<GarageDoorCloseResult> CloseAsync([In] AllJoynMessageInfo info);
IAsyncOperation<GarageDoorPushButtonResult> PushButtonAsync([In] AllJoynMessageInfo info);
IAsyncOperation<GarageDoorGetIsOpenResult> GetIsOpenAsync([In] AllJoynMessageInfo info);
IAsyncOperation<GarageDoorGetIsPartiallyOpenResult> GetIsPartiallyOpenAsync([In] AllJoynMessageInfo info);
}
The full source code for the project can be found on GitHub:
https://github.com/hastarin/HastPiControl
Can anyone tell me if I'm doing something wrong, or if perhaps this is a limitation of the AllJoyn Studio Extension?
Can anyone suggest a workaround?

I had the same issue. Then I stumbled across an example that used <arg> instead of <argument> for the element name. It worked for me - haven't had a chance to look into it further...

Related

Call mediator end point type(XPath)

In call mediator we can form endpoint using XPath (from the response).But the problem is endpoint is not calling.
<?xml version="1.0" encoding="UTF-8"?>
<api context="/xpath" name="call"
xmlns="http://ws.apache.org/ns/synapse">
<resource methods="GET" protocol="http">
<inSequence>
<call>
<endpoint key-expression="/root/a"/>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
following response is from postman.
<root>
<a>http://www.mocky.io/v2/5ca6db71340000132f76b192</a>
</root>
Expected response :
<root>
<name>abcd</name>
<no>82382832</no>
</root>
Firstly, when using the resolving endpoint (using key-expression), we cannot give the URL directly [1]. We have to have the endpoint defined beforehand and should give only the key of the endpoint in the payload.
Secondly, for the key-expression to parse the xpath, the message should be built beforehand. Since call mediator is content-unaware, it will not build the message. Therefore, we should use a content aware mediator to build the message.
Following is the sample inSequence that'd work.
<inSequence>
<log level="full"/>
<call>
<endpoint key-expression="//a"/>
</call>
<respond/>
</inSequence>
Now the payload should be like
<root>
<a>testEndpoint</a>
</root>
Edit:
The endpoint named 'testEndpoint' should be defined with the backend url.
You need to define an endpoint [2]. For example, I'm using an address endpoint.
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="testEndpoint">
<address uri="http://www.mocky.io/v2/5ca6db71340000132f76b192">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
Try this. I receieved needed response in Postman, but you should use POST method as your request has a Body.
<api xmlns="http://ws.apache.org/ns/synapse" name="call" context="/xpath">
<resource methods="POST">
<inSequence>
<property name="uri.var.httpendpointurl" expression="$body/root/a" scope="default" type="STRING"/>
<call>
<endpoint>
<http uri-template="{uri.var.httpendpointurl}"/>
</endpoint>
</call>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>

getting "org.apache.http.nohttpresponseexception the target server failed to respond" while calling wso2 http endpoint

I am getting below error while calling http endpoint:-
The endpoint is HTTP endpoint which I am using.
Also added timeout parameters in axis2.xml and axis2.blocking.xml.
But it did not work.
Can anyone provide any solution to it?
HTTPSender Unable to sendViaPost to url[http://*********]
org.apache.commons.httpclient.NoHttpResponseException: The server ****** failed to respond
at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1976)
at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1735)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1098)
the esb proxy looks like below:--
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="mqListener"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<log description="print message" level="full">
<property name="message" value=""In listenAbc1Mq""/>
</log>
<payloadFactory media-type="json">
<format>
{
"orderId": ""
}
</format>
<args>
<arg evaluator="xml" expression="//verkkopvc/text()"/>
</payloadFactory>
<log description="print message" level="full">
<property name="message" value=""after payload factory""/>
</log>
<property name="OUT_ONLY" value="true"/>
<property name="DISABLE_CHUNKING"
scope="axis2"
type="STRING"
value="true"/>
<call blocking="true">
<endpoint key="abc"/>
</call>
<log description="print message" level="full">
<property name="message" value=""Out sequence""/>
</log>
</inSequence>
<outSequence/>
<description/>
</proxy>
I believe the error is printed by your http client. To fix it, do these.
1) Remove <property name="OUT_ONLY" value="true"/>
2) Add <respond/> mediator at the end of inSequence.

How to catch tcp client request message in wso2 esb proxy service

Im new comer to Wso2 esb. Now I'm working with tcp protocol and proxy service. I have some question. I send some message to the proxy service through tcp protocol. I need get this message to the property mediator in the proxy service. But my way not catch that value in the property mediator.
Here is my proxy service
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="TCPProxyService" startOnLoad="true" transports="tcp" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<property description="" expression="get-property('message')" name="MessageValue" scope="default" type="STRING"/>
<log description="" level="custom">
<property name="property_name" value="============================="/>
<property expression="get-property('MessageValue')" name="inputValue"/>
</log>
<sequence key="in-sequence"/>
<log/>
<respond/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.tcp.responseClient">true</parameter>
<parameter name="transport.tcp.inputType">string</parameter>
<parameter name="transport.tcp.recordDelimiter">|</parameter>
<parameter name="transport.tcp.contentType">text/plain</parameter>
<parameter name="transport.tcp.port">6789</parameter>
<parameter name="transport.tcp.recordDelimiterType">character</parameter>
</proxy>
Here is my Java client for send tcp request
import java.io.*;
import java.net.*;
class TCPClient {
public static void main(String argv[]) throws Exception {
String delimiter = "|";
int modifiedSentence;
Socket clientSocket = new Socket("localhost", 6789);
DataOutputStream outToServer = new
DataOutputStream(clientSocket.getOutputStream());
BufferedReader inFromServer = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
String message = "Pietoo,Klaas,also" + delimiter;
outToServer.writeBytes(message);
outToServer.flush();
while ((modifiedSentence = inFromServer.read()) > -1){
System.out.print((char)modifiedSentence);
}
clientSocket.close();
}
}
I tried to add below property mediator with get-property expression. What is the wrong with this.
property description="" expression="get-property('message')" name="MessageValue" scope="default" type="STRING"/>
try a <log level="full"/> in your proxy def, send it a message with your java client and have a look to wso2-esb-service.log : you should see a soap message like this
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<text xmlns="http://ws.apache.org/commons/ns/payload">your|data</text>
</soapenv:Body>
</soapenv:Envelope>
You can get the text value with :
<property xmlns:tp="http://ws.apache.org/commons/ns/payload" name="MessageValue" expression="$body/tp:text"/>

Flex mobile using Parsley

I'm using Parsley in my flex mobile project. I have multiple destination services but I can't find more resources on how to add another destination service to config.xml file. The file is as below:
<objects
xmlns="http://www.spicefactory.org/parsley"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.spicefactory.org/parsley
http://www.spicefactory.org/parsley/schema/2.4/parsley-core.xsd">
<object type="mx.rpc.remoting.RemoteObject" id="genBUS">
<property name="destination" value="genBUS"/>
<property name="endpoint" value="http://localhost:8080/ClinASM/messagebroker/amf" />
</object>
</object>
In the case when I create another
<object type="mx.rpc.remoting.RemoteObject" id="anotherBUS"></objects>
and do
[Inject(id='genBUS')]
public var genBUS:RemoteObject;
it complains that I have defined multiple remote objects. How does it work? How can I inject another destination service? That would be great to gain more knowledge about Parsley...
UPDATE: config.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Object
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns="http://www.spicefactory.org/parsley">
<Object id="genBUS" type="mx.rpc.remoting.RemoteObject">
<Property name="destination" value="genBUS" />
<Property name="endpoint" value="http://localhost:8080/ClinASM/messagebroker/amf" />
</Object>
<Object id="karBUS" type="mx.rpc.remoting.RemoteObject">
<Property name="destination" value="karBUS" />
<Property name="endpoint" value="http://localhost:8080/ClinASM/messagebroker/amf" />
</Object>
</mx:Object>
Injecting by ID is not considerer to be good practice because you create a name-based dependency. Change the name, or make a typo, and your application breaks and it's hard to debug that.
So as a general rule you should try to avoid it. The Parsley docs explain how to do this. I'll just add a simple example to show you how you'd use that technique with your multiple RemoteObjects.
<fx:Object xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:p="http://www.spicefactory.org/parsley">
<fx:Script>
import path.to.service.GenBusDelegate;
import path.to.service.KarBusDelegate;
</fx:Script>
<fx:Declarations>
<fx:String id="gateway">http://localhost:8080/ClinASM/messagebroker/amf</fx:String>
<s:RemoteObject id="genBus" destination="genBus" endpoint="{gateway}" />
<s:RemoteObject id="karBus" destination="karBus" endpoint="{gateway}" />
<p:Object type="{GenBusDelegate}">
<p:ConstructorArgs>
<p:ObjectRef idRef="genBus" />
</p:ConstructorArgs>
</p:Object>
<p:Object type="{KarBusDelegate}">
<p:ConstructorArgs>
<p:ObjectRef idRef="karBus" />
</p:ConstructorArgs>
</p:Object>
</fx:Declarations>
</fx:Object>
or if you don't want to use constructor arguments:
<p:Object type="{GenBusDelegate}">
<Property name="remoteObject" idRef="genBus"/>
</p:Object>

The ProxyFactoryFactory was not configured

Considering this example as a base example, I created the application but when I execute this application I am getting the following error.
The ProxyFactoryFactory was not configured. Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers. Example: NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu Example: NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
The following is the code snippet I am using.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NHibernate;
using NHibernate.Cfg;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Configuration cfg = new Configuration();
cfg.AddAssembly("NHibernate");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
User newUser = new User();
newUser.Id = "joe_cool";
newUser.UserName = "Joseph Cool";
newUser.Password = "abc123";
newUser.EmailAddress = "joe#cool.com";
newUser.LastLogon = DateTime.Now;
// Tell NHibernate that this object should be saved
session.Save(newUser);
// commit all of the changes to the DB and close the ISession
transaction.Commit();
session.Close();
}
}
And my app.config file looks like
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MsSql2000Dialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.SqlClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI"
/>
<!--<add value="nhibernate.bytecode.castle.proxyfactoryfactory, nhibernate.bytecode.castle" key="proxyfactory.factory_class" />-->
<!--<property name="proxyfactory.factory_class">NHibernate.ByteCode.Linfu.ProxyFactoryFactory, NHibernate.ByteCode.Linfu</property>-->
<!-- I have tried both the lines but still getting the same error -->
</nhibernate>
</configuration>
I have LinFu.DynamicProxy.dll instead of linfu.dll. Will it work? If not, then from where do I get this linfu.dll?
Or is there any other solution?
Assuming you have NHibernate 2.1 Alpha3, copy LinFu.DynamicProxy.dll and NHibernate.ByteCode.LinFu.dll from \Required_For_LazyLoading\LinFu to your bin (or references)
Then your configuration line should work:
<add key="proxyfactory.factory_class" value="NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu" />
As an aside, I prefer the hibernate-configuration section block for configuration.
Edit: Here's the relevant sections from my web configuration if you wanted to set up with hibernate-configuration instead of key/value pairs.
Also, it's possible to just put the hibernate-configuration part in its own file called hibernate.cfg.xml. You can then use the xsd nhibernate-configuration.xsd that's in the download to validate your configuration.
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="default_schema">kennelfinder.dbo</property>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="proxyfactory.factory_class">
NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu
</property>
<property name="connection.connection_string">{Your connection string}</property>
<property name="show_sql">false</property>
<property name="connection.driver_class">
NHibernate.Driver.SqlClientDriver
</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="use_proxy_validator">true</property>
<mapping assembly="KennelFinder"/>
</session-factory>
</hibernate-configuration>
We actually use Castle Proxy and have the following.
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
After that it's just a matter of making sure that ALL of the files in the NHibernate Castle lazy loading directory are in the bin.
LinFu.DynamicProxy.dll isn't enough. You also need NHibernate.ByteCode.Linfu.dll (and potentially others).
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.provider"> NHibernate.Connection.DriverConnectionProvider </property>
<property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
<property name="connection.connection_string">Server=(local);database=HelloNHibernate;Integrated Security=SSPI;</property>
<property name="show_sql">false</property>
<property name="connection.driver_class"> NHibernate.Driver.SqlClientDriver </property>
<property name="connection.isolation">ReadCommitted</property>
<property name="use_proxy_validator">true</property>
</session-factory>
</hibernate-configuration>
</configuration>
Copy LinFu.DynamicProxy.dll and NHibernate.ByteCode.LinFu.dll to the NHibernate's folder and add the same DLL files to the project reference.
I got this error after publishing my project via Visual Studio 2008's right-click "Publish..." feature, when trying to push our MVC/NHibernate project out to our web server.
It turned out I just needed to set the correct options in the publish dialog. In particular, in the "Copy" section, specify "All files in the source project folder", and then it started working. "Only files needed to run this application" was not good enough, perhaps Visual Studio was not smart enough to figure out which DLLs were being lazy loaded?
rnate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>

Resources