Giter VIP home page Giter VIP logo

Comments (5)

raymondfeng avatar raymondfeng commented on September 26, 2024

Can you uncomment the wsdl property and set it to:

http://api.daft.ie/v2/wsdl.xml?wsdl

Thanks,


Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop http://strongloop.com/ makes it easy to develop APIs http://strongloop.com/mobile-application-development/loopback/ in Node, plus get DevOps capabilities http://strongloop.com/node-js-performance/strongops/ like monitoring, debugging and clustering.

On Oct 20, 2014, at 4:20 PM, Gianfranco Palumbo [email protected] wrote:

var soap = require('soap');
var url = 'http://api.daft.ie/v2/wsdl.xml';

soap.createClient(url, function(err, client) {
var args = {
'api_key': '...', // i can send this via email if needed
};
client['search_sale'](args, function%28err, result%29 {
if %28err%29 {
console.log%28err%29;
return;
}
console.log%28result%29;
});
});
$ node soap.js
{ results:
{ search_sentence: 'properties for sale anywhere in Ireland entered by',
pagination:
{ total_results: 35,
results_per_page: 10,
num_pages: 4,
current_page: 1,
first_on_page: 1,
last_on_page: 10 },
ads:
[ [Object],
[Object],
...
[Object],
[Object] ] } }
var loopback = require('loopback');
var path = require('path');

var ds = loopback.createDataSource('soap', {
connector: 'loopback-connector-soap',
// remotingEnabled: true,
url: 'http://api.daft.ie/v2/wsdl.xml',
// wsdl: 'http://api.daft.ie/v2/wsdl.xml',
operations: {
searchSale: {
service: 'DaftAPIService',
port: 'DaftAPIService',
operation: 'search_sale'
}
}
});

var args = {'api_key': '...'}; // i can send this via email if needed

// Unfortunately, the methods from the connector are mixed in asynchronously
// This is a hack to wait for the methods to be injected
ds.once('connected', function () {
// Create the model
var DaftService = ds.createModel('DaftAPIService', {});

DaftService.searchSale(args, function (err, response) {
if (err) {
console.log('error: %j', err);
return;
}
console.log('response: %j', response);
});

});
$ node daft.ie.soap.js
Connection fails: [Error: Invalid WSDL URL: http://api.daft.ie/v2/wsdl.xml?wsdl

Code: 404

Response Body: <!DOCTYPE html

Reply to this email directly or view it on GitHub #6.

from loopback-connector-soap.

gianpaj avatar gianpaj commented on September 26, 2024

Hi Ray,

thanks for the quick reply. That didn't work.
It seems it's not reading the xml definitions and instead getting the html from daft.ie

I tried also downloading the wsdl.xml file and loading it as a file.

In this case I get:

error: {
    "response": {
        "statusCode": 301,
        "body": "",
        "headers": {
            "server": "Varnish",
            "retry-after": "0",
            "location": "http://www.daft.ie/v2/wsdl.xml",
            "date": "Mon, 20 Oct 2014 23:33:54 GMT",
            "x-varnish": "2053246842",
            "age": "0",
            "via": "1.1 varnish",
            "connection": "close",
            "x-varnish-cache-result": "Miss"
        },
        "request": {
            "uri": {
                "protocol": "http:",
                "slashes": true,
                "auth": null,
                "host": "api.daft.ie",
                "port": 80,
                "hostname": "api.daft.ie",
                "hash": null,
                "search": null,
                "query": null,
                "pathname": "/v2/wsdl.xml",
                "path": "/v2/wsdl.xml",
                "href": "http://api.daft.ie/v2/wsdl.xml"
            },
            "method": "POST",
            "headers": {
                "User-Agent": "node-soap/0.4.7",
                "Accept": "text/html,application/xhtml+xml,application/xml,text/xml;q=0.9,*/*;q=0.8",
                "Accept-Encoding": "none",
                "Accept-Charset": "utf-8",
                "Connection": "close",
                "Host": "api.daft.ie:80",
                "Content-Length": 0,
                "Content-Type": "text/xml; charset=utf-8",
                "SOAPAction": "\"DaftAPIService#agent_info\""
            }
        }
    },
    "body": ""
}

So i'm getting a 301 instead of 200 and there is no API key.

But if I don't put an API key in the first soap example, i get an error 500.

from loopback-connector-soap.

raymondfeng avatar raymondfeng commented on September 26, 2024

I assume there are two issues:

  1. Having trouble loading the wsdl from http://api.daft.ie/v2/wsdl.xml?wsdl
  2. Failing to pass in the api key. How should the api key be passed in? Via a header?

from loopback-connector-soap.

gianpaj avatar gianpaj commented on September 26, 2024

Yes. I think the first you're right. But the second I don't think it's the API. As there HTTP code does not change if you send the API or not.

If there is no API key it should return error 500.

But in either case, the api_key should be passed as an argument of the service along side with the query.
Would it be better if I send you my API key via email?
Thanks

from loopback-connector-soap.

gunjpan avatar gunjpan commented on September 26, 2024

Closing due to inactivity. If you are still running into problems, please feel free to leave a comment and I will reopen the issue.

from loopback-connector-soap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.