Sending my app a command in Cortana just searches Bing for my query string - win-universal-app

I am writing a Cortana "background app", and trying to call it from Cortana. Here is my VCD file:
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
<CommandSet xml:lang="en-us" Name="MinimalCommandSet_en-us">
<AppName>Mini</AppName>
<Example>test foo</Example>
<Command Name="TestCommand">
<Example>test foo</Example>
<ListenFor>test foo</ListenFor>
<Feedback> Testing... </Feedback>
<VoiceCommandService Target="VoiceCommandService"/>
</Command>
</CommandSet>
</VoiceCommands>
I go and type "Mini test foo" in Cortana, but it just searches Bing for "Mini test foo". How can I avoid that?

You might not be taking a "deferral", which signals to the OS that your app shouldn't be terminated just yet. Remember to call taskInstance.getDeferral(), and hold on to the resulting object until your app finishes handling the Cortana request.

Related

How to create malformed XML (SOAP request) in nodejs

I have been given a task to generate malformed SOAP Request and checking for what kind of error response I receive.
For example:
const payload = `
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:test="urn:TEST"
>
<soap:Body>
<test:GetOperatingDataValues
xmlns:test="urn:TEST"
>
<test:ListId>1</test:ListId>
</test:GetOperatingDataValues>
</soap:Body>
</soap:Envelope>`
Now, if I send the above request body to the backend server like :
const result = axios.post("backendServer", payload)
console.log(result) will give the response from backend (in this case, response from GetOperatingDataValues function for listId 1)
Now, I have to modify that payload in different ways like, removing the end tag, different opening and closing tag names, deleting '<' from any tag, or removing '/' from end tags, different method name, etc and send that payload and check for the error response.
Is there any way to modify the correctly formed xml to malformed xml (in node js).
I have gone through different packages such as xml2js, fast-xml-parser. But these packages just form the correct xml.
Any help would be highly appreciated.
I would have thought it fairly obvious that to create a non-XML file, you don't want to use an XML tool. Just treat the XML as a character string and apply a regular expression, for example replacing </ by <.

Mule - How to send SOAP Web Service Request?

Hi i am doing simple POC in mule.
I have a web service and i want to make it's Client.
It is SOAP web service and i want to send request to it but i am not getting wayout. Please give me some idea.
Following is code:
MULE:
<cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
<flow name="prjvm1" doc:name="prjvm1">
<http:inbound-endpoint address="http://localhost:5678/httpHello" contentType="application/x-www-form-urlencoded" doc:name="HTTP">
<http:body-to-parameter-map-transformer />
</http:inbound-endpoint>
<!-- This logger is just set to show the message accepted from the request -->
<logger level="INFO" message="#[payload]" doc:name="Logger"/>
<cxf:jaxws-client doc:name="VimService"
wsdlLocation="file:/C:/Users/gugla/MuleStudio/workspace/prjvm/bin/service/vService.wsdl"
operation="retrieveServiceContent"
clientClass="com.esxclient.VService"
port="VimPort">
<cxf:jaxb-databinding/>
</cxf:jaxws-client>
<outbound-endpoint address="http://localhost:8080/gep-sped/servicos/ServicoDeCadastroEAgendamento"
doc:name="Generic"
exchange-pattern="request-response"/>
<echo-component doc:name="Echo"/>
</flow>
I am getting exception, but operation is there in WSDL
Message : No such operation: retrieveServiceContent. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ManagedObjectReference
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. No such operation: retrieveServiceContent (java.lang.Exception)
org.mule.module.cxf.CxfOutboundMessageProcessor:282 (null)
2. No such operation: retrieveServiceContent. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: ManagedObjectReference (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.Exception: No such operation: retrieveServiceContent
at org.mule.module.cxf.CxfOutboundMessageProcessor.getOperation(CxfOutboundMessageProcessor.java:282)
at org.mule.module.cxf.CxfOutboundMessageProcessor.getMethodFromOperation(CxfOutboundMessageProcessor.java:322)
at org.mule.module.cxf.CxfOutboundMessageProcessor.getMethod(CxfOutboundMessageProcessor.java:259)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
Following is WSDL in operation: I am confused and around 4 days on it as i am new to mule.
<operation name="RetrieveServiceContent">
<input message="vim2:RetrieveServiceContentRequestMsg" />
<output message="vim2:RetrieveServiceContentResponseMsg" />
<fault name="RuntimeFault" message="vim2:RuntimeFaultFaultMsg"/>
</operation>
There are a couple of ways to do this. I prefer to NOT us the way MuleStudio wants you to do it since I never really got that to work. Basically, whenever I create a webservice client my mule-config looks something like this:
<custom-transformer class="nl.thorax.someprogram.transformers.SomeRequestTransformer
<https:outbound-endpoint ref="someEndpoint" >
<cxf:jaxws-client
clientClass="nl.thorax.someprogram.someclass"
wsdlLocation="http://somedomain?wsdl
port="somePort"
operation="someOperation"/>
</https:outbound-endpoint>
<custom-transformer class="nl.thorax.someprogram.transformers.SomeResponseTransformer
Where:
SomeRequestTransformer: a transformer to create your request.
someEndpoint: some endpoint defined in your MuleConfig. In my example, this is https but it could also be plain http.
someclass: Important! This is your client class. It can be generated from a WSDL by free tools like Apache's WSDL2Java. Google is your friend on this.
somePort: The port in your webservice to use. It can usually be found in the WSDL itself or in the client class you generated. The port more or less specifies what operations you can use.
someOperation: The operation you want to use. Make sure it is typed EXACTLY the same as it's definition in the client class. Wrong use of cApItAlS will cause errors!
SomeResponseTransformer: a transformer to do something with your response.
Now, the way I configure the call (and parse the response for that matter) is to use POJOs. My first transformer, the SomeRequestTransformer (based on the AbstractMessageTransformer in the Mule library) has a bit of code looking like this:
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException
{
RequestObject request = new RequestObject();
request.setText("Hello!");
message.setPayload(request);
return message;
}
I create the request, set the variables and return it to Mule. The RequestObject is a class generated by WSDL2Java and corresponds to some operation in the WSDL. Parsing the response works pretty much the same way.
Now I know from experience that a lot of webservices do not quite work in the same way. Try to implement my example yourself. If that doesn't work, please provide your Mule-Config and any and all Java classes you may be using.
EDIT:
I've created an example of my method that actually works. The files can be downloaded at our website. Please see the comments in the files. You have to manually create the Mule project, of course.
Points of note for the example:
The XML-representation of the Mule-config can be found in the 'resources' folder in the archive.
The 'nl.example.example' folder contains all the generated JAX-WS files.
The WSDL location in Mule-config has to be changed since it contains an absolute path.
The example creates an endpoint at http://localhost:8088 for you to call. The flow contains a transformer which creates an example call using pre-defined parameters. Then it tries to connect to the webservice. I've used the default address used by SOAPUI when you create a mock service, but this could of course be changed into anything you want. The webservice (supposedly) returns something which is echoed into the user's browser.
In this example, the parameters are actually Strings, since the WSDL-request doesn't contain anything. To figure out what object to pass to the cxf:jaxws-client look at the operation definition which can be found in the Port definition in your generated files.

How to autostart j2me application on foreground?

I'm trying to make my j2me application to auto-start when the phone is powered on. (The phone is Sonim XP1301.)
I added jad attribute "MIDlet-Launch-Power-On: yes", and now application starts automatically but stays on the background... This is useless for me because the application is UI-based and requires user interaction...
Is there any other jad attribute that would force the application to start in foreground, or some j2me command to bring the application to foreground?
Edit: At Sonim developer site I found this:
"We have our emulator library in which you can check whether the application is in background. Once you get the result you can bring it to foreground
JavaBackgroundMode.isRunningInBackground(Midlet m); is used to check whether the Midlet is in background. If it returns true then it means it is in the background.
JavaBackgroundMode.bringToForeground(this); is used to bring an app to foreground."
..But I have NO IDEA what this actually means... What "emulator library"? Where can I download it and how to use it? If I try just to add this line to my code:
JavaBackgroundMode.bringToForeground(this);
..NetBeans gives me error "Cannot find sybmol: Variable JavaBackgroundMode".
Any ideas?
Edit2: Tested "push registry", does not work. JAD file looks like this:
MIDlet-1: Contactless,,example.contactless.ContactlessDemo
MIDlet-Description: This is basic JSR257 Contactless Communication API demo.
MIDlet-Jar-Size: 7738
MIDlet-Jar-URL: Contactless.jar
MIDlet-Name: Contactless
MIDlet-Permissions: javax.microedition.io.Connector.file.read, javax.microedition.io.Connector.file.write, javax.microedition.io.Connector.http, javax.microedition.io.PushRegistry
MIDlet-Push-1: autostart://:, Contactless, *
MIDlet-Vendor: Oracle
MIDlet-Version: 1.0
Manifest-Version: 1.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0
I never heard of MIDlet-Launch-Power-On before. Had to Google for it to learn that it is a Sprint specific JAD attribute.
Try using the standard way of auto-starting a MIDlet: Using PushRegistry.
Add these two lines in your JAD file instead, and remove the MIDlet-Launch-Power-On attribute.
MIDlet-Permissions: javax.microedition.io.PushRegistry
MIDlet-Push-1: autostart://:,NameOfMIDlet,*
See if that makes a difference.
Oracle-MIDlet-Autostart: 1
Oracle-MIDlet-Restart: false
Oracle-MIDlet-Restart-Count: 10
Just an additional answer to this question:
Every MIDlet that is started automatically needs to be configured via its jad file and the following properties:
Oracle-MIDlet-Autostart: [0-5], autostart order. 0 means no autostart. For MIDlets with
the same level the order is not defined.
Oracle-MIDlet-Restart: [true|false], if true the MIDlet is automatically restarted if it terminates non gracefully, e.g. by an uncaught exception.
Oracle-MIDlet-Restart-Count: [number], number of allowed MIDlets restarts before the
whole module is rebooted

ActiveSync Sync message not supporting all properties

I'm implementing an ActiveSync Java client. I can already communicate with the server and perform the protocol sequence to Sync emails, as defined in the documentation.
However, when I try and send a Sync command it seems I can only use a subset of the available commands in the specification. When I use certain property tags in the Sync XML message I receive a Status 4 ('Protocol Error') code, even though these should be valid according to the specification.
When I use only the GetChanges property I do get a proper response, however I'd like to be able to specify how many items to return etc.
I've included the XML snippet that I'm sending: the commented out lines are lines that were attempted but caused a Status 4.
<?xml version="1.0" ?>
<Sync xmlns="AirSync:">
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>{23423972324}</SyncKey>
<CollectionId>{23423sdfsdfsdfsf972324}</CollectionId>
<GetChanges/>
<!--<GetChanges>0</GetChanges>-->
<!--<WindowSize>512</WindowSize>-->
<!--<Options>-->
<!--<Class>Email</Class>-->
<!--<FilterType>3</FilterType>-->
<!--<MaxItems>10</MaxItems>-->
<!--</Options>-->
<!--<Commands>-->
<!-- <Fetch>-->
<!-- <ServerId>1:323</ServerId>-->
<!-- </Fetch>-->
<!--</Commands>-->
</Collection>
</Collections>
<!--<WindowSize>512</WindowSize>-->
</Sync>
Is there any reason why these properties shouldn't be supported? Or is there something I've left out of the message?
The GetOptions command for the server returns the following (truncated):
Server: Microsoft-IIS/6.0,
X-Powered-By: ASP.NET,
Pragma: no-cache,
Public: OPTIONS, POST, Allow: OPTIONS, POST,
MS-Server-ActiveSync: 6.5.7653.19,
MS-ASProtocolVersions: 1.0,2.0,2.1,2.5,
MS-ASProtocolCommands:Sync,SendMail,SmartForward,SmartReply,GetAttachment,GetHierarchy,CreateCollection,DeleteCollection,MoveCollection,FolderSync,FolderCreate,FolderDelete,FolderUpdate,MoveItems,GetItemEstimate,MeetingResponse,ResolveRecipients,ValidateCert,Provision,Search,Notify,Ping
It turns out that the WBXML encode/decoder I was using wasn't working correctly. I figured this out by comparing the byte code generated by two different WBXML encoders and saw a difference. The encoder I was using didn't process empty elements like properly. I fixed it and now the server acts as expected.

How to get the new message id after a sync/delete request

When a message is deleted, my application will send a Sync request with a Delete command within the Commands element. The application also sets the DeletesAsMoves option so that the message is not deleted permanently, but instead moved to the Deleted Items folder. This all works great. However, my challenge is to now move the message back out of the Deleted Items folder. This is failing because once the message is deleted in the Sync command, its message id changes.
In the MoveItems request, the new message id comes back in the response. Is there a similar way for me to track the changed message id after a Sync/Delete command?
Below is the request:
<?xml version="1.0"?>
<Sync>
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>{F8654B17-4BF2-439F-9875-22EDDE1138FF}154</SyncKey>
<CollectionId>03cd385d379ece4988b9c88834382ea7-68cc1f</CollectionId>
<DeletesAsMoves/>
<GetChanges/>
<WindowSize>50</WindowSize>
<Options>
<FilterType>2</FilterType>
<Truncation>7</Truncation>
</Options>
<Commands>
<Delete>
<ServerId>3:225</ServerId>
</Delete>
</Commands>
</Collection>
</Collections>
</Sync>
And the response:
<?xml version="1.0"?>
<Sync>
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>{F8654B17-4BF2-439F-9875-22EDDE1138FF}155</SyncKey>
<CollectionId>03cd385d379ece4988b9c88834382ea7-68cc1f</CollectionId>
<Status>1</Status>
</Collection>
</Collections>
</Sync>
The response indicates that the delete command was successful, however the message is now in another folder with an entirely new ServerId. I would like to be able to know what that new ServerId is.

Resources