i build a web service project by wash_out gem ,i can call functions use the Savon gem ,but when i tried to connect to my webservice server by soap.jar in java; its doesn't work , how to write the url of functions? and how to send actions by get(default is post ,so rails will throw the routing error,because wash_out generate wsdl routes in GET way);
here is my code
class HxppController < ApplicationController
soap_service namespace: 'urn:WashOut'
soap_action "CreateOrUpdateDictionary",
:args => {ZTYPE: :string, ZCODE: :string, ZDESC: :string },
:return => {:ZRTN_CODE => :string, ZRTN_RESULT: :string}
def CreateOrUpdateDictionary
render :soap => {:ZRTN_CODE => "S", ZRTN_RESULT: "success"}
end
end
My webservice url is localhost:3000/hxpp/wsdl ;
how to fix this? thanks a lot
Related
I am not sure if this question gonna be considered as duplicated or not, but I wasn't able to find my answer even by googling or through out the QA suggested topics on the SOF. So here I go asking my question:
I have developed a website with Javascript, PHP , AJAX that's using JSON to talk to eachother. And now the client is asking me to change all PHP backend to Spring Boot. That means I gonna talk to the HTML and Javascript and MySql using Java EE Spring Boot and I am not sure how I gonna do it. My main problems are:
1- Is it possible to parse data from Java to the jQuery using JSON ? I mean I retrive data from the MySql and then send it back to the .php file.
The PHP example would be:
$myJSON = json_encode($myObj);
echo $myJSON;
2- Is it possible to get the parsed the respons from the JAVA through the jQuery :
jQuery.ajax({
type:"post",
dataType:"json",
url: myAjax.ajaxurl,
data: {action: 'submit_data', info: info},
success: function(getParsedVAL) {
// the variable getParsedVAL is comming from the JAVA file
successmessage = 'Data was succesfully captured';
$("label#successmessage").text(successmessage);
},
error: function(getParsedVAL) {
// the variable getParsedVAL is comming from the JAVA file
successmessage = 'Error';
$("label#successmessage").text(successmessage);
},
});
success: function(getParsedVAL) {
// the variable getParsedVAL is comming from the JAVA file
successmessage = 'Data was succesfully captured';
}
I’m actually transitioning to spring boot from php. Spring boot actually encodes the java object to json automatically. If you developed the back end with some lightweight framework with routing and model controller structure you can easily convert it to spring boost
I am building a cordova application using the cordova-plugin-passbook plugin, which can be seen here: https://github.com/passslot/cordova-plugin-passbook.
I am trying to consume a pkpass from our java server that is returning the file as expected if we directly hit our service from a browser, but the problem is that we need to use an auth token and go through our oAuth server first. So I must request the pass via ajax in my front end using Angular.
The data I get back is an octet-stream and somehow I need to parse it and get it to work with the plugin above. The plugin is configured to look for a url ending in ".pkpass", I am wondering if it can be configured to look for the parsed data instead of a url.
Can anyone see in the src of the plugin if there is a possible way to do that? I am not very familiar with objective c, but just trying to think of options.
Thanks
Using cordova fileTransfer plugin, I got this working:
fileTransfer.download(
uri,
fileURL,
function(entry) {
Passbook.downloadPass(fileURL);
},
function(error) {
alert('Error retrieving pass, please try again in a little while.');
},
true,
{
headers: {
"Authorization": "Bearer " + LS.get( 'user_token' )
}
}
);
I've got a RESTful call that I'd like to make to the back end of my application. The front end is written in Ext JS (JavaScript) the back-end in JAVA utilizing Hibernate. The application utilizes the MVC design pattern.
On the back end, I've got a GET request endpoint with a "mapping" akin to: thing/{thingOne}/otherThing/{thingTwo}.
Ext JS provides a number of functions on their stores for hitting a back end through a model's proxy: .load(), .save(), .remove(). Each of these is able to take multiple arguments for their [options] parameter; however, I am attempting to find documentation that shows me how to make a multi-parametered request to a back-end GET endpoint and have found none, so far.
My assumption is that the call would be structured like: .load("param1", "param2") based upon the documentation for .save() and .remove(). Here's the doc. for save, for remove, and load.
So, how do I make a GET call to the back end with multiple parameters? Am I even in the correct ballpark?
You can use "extraparams" on proxy.
sencha api 4.2.2 - extraparams on store
var formOperation = [];
var example = {"city":"Manchester"};
Ext.Object.merge(formOperacion,example);
store.getProxy().extraParams = formOperation;
store.load();
Another solution:
Sencha api - store - Dynamic Loading
store.load({
params: {
group: 3,
type: 'user'
},
callback: function(records, operation, success) {
// do something after the load finishes
},
scope: this
});
Build the request's URL as a concatenated string, including the arguments:
var requestUrl = 'thingOne/' + thingOneVar + '/otherThing/' + otherThingVar;
Note that whether your "built" string should be prefixed with a / depends upon how your model's proxy is configured. Essentially, you are aiming for a legitimate request url.
And make a request via the proxy (here, I'm using AJAX):
Ext.Ajax.request({
url : requestUrl,
// ....
});
The then needs to be handled by a callback or as a promise.
This is largely a new area for me, so my question is more on helpful resources.
I have an apache server running on port 80 that simply hosts a javascript application.
This java application gets its data through rest calls made to a java application running in jetty on port 8080.
For the front end I am using AngularJS. My request service looks like this:
(function(ng, app){
"use strict";
app.service(
"questService",
function( $q, $http, _, categoryService ) {
function($q, _, $http){
function getQuestsFromServer(){
$http({method: 'GET', url: 'http://localhost:8080/worldcraft/quests'}).
success(function(data, status, headers, config) {
console.log("SUCESS!! {status: " + status + " \nData:" + data + "}");
}).
error(function(data, status, headers, config) {
console.log("FAILURE!! {status: " + status + " \nData:" + data + "}");
});
}
}
return getQuestsFromServer : getQuestsFromServer;
})
})(angular, Worldcraft);
in the java application I have a service like this
#Singleton
#Produces(MediaType.APPLICATION_JSON)
#Path("worldcraft/quests")
public class QuestbookService {
private Questbook questbook;
#Inject
public QuestbookService(Questbook questBook) {
this.questbook = questBook;
}
#GET
#Produces(MediaType.APPLICATION_JSON)
public List<Quest> getQuests() {
return questbook.getQuests();
}
}
When using chrome to test this, I get the javascript exception: XMLHttpRequest cannot load http://www.myserver.com:8080/worldcraft/quests. Origin http://www.myserver.com is not allowed by Access-Control-Allow-Origin.
After doing research, it seems the correct solution is using JSONP. But I haven't seen anything online that really helps me understand how to do this with the technology I Have in place.
The java stack is using jetty, jackson, jersy, with guice to facade the servlets.
The front end stack is using AngularJS to do the routing.
The AngularJS platform is hosted on port 80 with a regular Apache server.
any advice or tips would be nice, research topics would be preferred. Or an explanation of what I may be doing wrong.
Your Java application running on port 80 must write a specific header to its response stream:
Access-Control-Allow-Origin: *
Since you have 'static' content hosted on your :80 site, you will have to ask Apache to add this header via mod_headers. Create a .htaccess file in the root directory with this content:
<filesmatch ".*">
Header set Access-Control-Allow-Origin "*"
</filesmatch>
Where the parameter defines Caller URIs individually separated by the pipe (|) sign, or * as wildcard.
The reason you're getting this error is because the browser implements the 'same origin policy'.
This change needs to be implemented on your source application.
You can read the header reference here.
I have the php webservice code below, what I am suppose to do, so that I can call this web service in java.
I need to generate the wsdl first? Then generate the java web service stubs with the wsdl? How can I call this in java. And what tool I need to use. Thank you.
<?php include_once("../../lib/config.php"); ?>
<?php
if(!extension_loaded("soap")){
dl("php_soap.dll");
}
ini_set("soap.wsdl_cache_enabled","0");
$server = new SoapServer("membersearch.wsdl");
function doMyMemberSearch($membernumber){
$sqlMemberInfo = mysql_query("SELECT * FROM Member_Info WHERE Member_Number = '".$membernumber."'");
$rowMemberInfo = mysql_fetch_array($sqlMemberInfo);
$arr[] = array(
"anniversary" => $rowMemberInfo['Anniversary'],
"club" => $rowMemberInfo['Club'],
"level"=> $rowMemberInfo['Level'],
"delivery"=> $rowMemberInfo['Delivery'],
"firstname"=> $rowMemberInfo['First_Name'],
"lastname"=> $rowMemberInfo['Last_Name'],
"birthday"=> $rowMemberInfo['Birthday'],
"spousefirst"=> $rowMemberInfo['Spouse_First'],
"spouselast"=> $rowMemberInfo['Spouse_Last'],
"spousebirthday"=> $rowMemberInfo['Spouse_Birthday'],
"signuploc"=> $rowMemberInfo['Signup_Loc'],
"status"=> $rowMemberInfo['Status']
);
if (isset($rowMemberInfo['Anniversary'])) {
return $arr;
}else {
throw new SoapFault("Server","Unknown Member Number '$membernumber'.");
}
}
$server->AddFunction("doMyMemberSearch");
$server->handle();
?>
WSDL is implementation language agnostic. So it doesn't matter if it was written in PHP, C#, Java or any other language.
You need to get the .wsdl file for the service. Usually you can get that by pointing your browser at the service URL with the addition of a query string '?WSDL'.
Example:
http://www.example.com/theWebService?WSDL
Once you have that you can use Apache CXF, Apache Axis2, Spring WS or any other web services framework to generate java client stub code.