calling web services from UNIX - web-services

I have a requirement to kickoff a workflow which is in salesforce.com thorugh web service from UNIX box. Can any one suggest me options or guide lines to achive this scenario?

I don't think you can just "kick off workflows". You'll have to perform an insert or update of records in Salesforce that will satisfy the workflow's entry criteria.
There's a Java tool called Data Loader for your basic data manipulation activities (you can download it from your own production org)
and it can be scripted for scheduled runs, has config file where you can store user's password in secure way etc. Check out the pdf guide for more ("Command Line Quick Start" chapter)
So I don't think you really need a webservice call...
Unless I misunderstood and you're talking about calling an Apex class' method that has "webservice" keyword and it will somehow perform the updates?
In that case you'll need to download the WSDL file generated for this class (Setup->Develop->Classes) and well, consume it in language of your choice (Java, PHP, Python... this link will help, steps aren't too different), then do your command line magic?
http://wiki.developerforce.com/page/Integration has tons of resources for you :)

Salesforce uses SOAP for their web service. They don't have restful web services now. Just request them to give the wsdl file.
Use this wsdl file to generate the java code. After that get their webService url so that you can proceed with your data pulling
This link may help you..
http://salesforce-walker.blogspot.in/2011/12/to-access-salesforce-data-from-java-we.html
Hope this helps

Related

How to mock SOAP web service without SoapUI

I have a web service that I want to mock in following way: I will have a list of given IDs, and a set of response items for them, and if user will send a request with ID from the list, proper response should be sent back.
How to do it without tools like SoapUI (I don't want to install any additional software on the server that will be tested if possible).
Thanks in advance for any help.
SoapUI open source provides exactly what you want to achieve, without any need to install SoapUI on the server.
I consider this approach very efficient:
Create your mock service inside SoapUI.
Test the mock on your computer with SoapUI.
Create a WAR with the mock service (or more services) - just click on the project and choose "Deploy As WAR"
Deploy the WAR to the target server.
The resulting WAR is standalone and you do not need to deploy any other software.
I recommend this tutorial: https://www.soapui.org/soap-mocking/getting-started.html
Regards,
Karel
The easiest way I could find is https://www.mockable.io/ . Hope it helps.
You might have to build an actual mock for this.
This could range from just a different implementation for an existing interface (say IOrderQuerier, with the old OrderQuerier and the new MockOrderQuerier), to a different project altogether (say MockOrderApi).
In both scenarios, the Mock would just return a set of predefined values depending on the input, but you'll need to provide some sort of switch mechanism (for example a flag in the config file, which is read by the DI container).
You'll have to provide more details about the server if you need more targeted answers on this.
If you can manage to mock this using mockito, I've just added a simple project which does most of the heavy lifting: mockito-soap-cxf

Does the existence of a .wsdl file mean files must be generated?

When I'm tasked with dealing with connecting to web services, I've always found the appropriate .wsdl file, ran WSDL2Java.bat, and incorporated those Java files into my Java project. Then I've successfully completed my project that needs to access data via web services.
My question is, are there other ways to use the .wsdl file to access web services? ( I'm not talking about creating classes for different languages ). For example, I have documentation describing one company's web services. The examples it shows in it's documentation are essentially dumps of HTTP Post requests. Is this "web services"? It looks to me that the .wsdl file is merely used as a reference to make the correct Post requests. I could just make text templates and plug in the right values, and send them out, right? I really feel like I'm missing something here.
Am I a web-services illiterati?
To call a SOAP web service over HTTP you just need to send it a properly formatted XML with a POST request. That's it! How you build the request is irrelevant as long as it conforms to the SOAP protocol and the payload corresponds to a proper web service operation that exists on the particular web service you are calling.
But how do you know how to build the proper payload?
The web service needs to have some sort of documentation otherwise you don't know what to put inside the XML. The documentation can be whatever you like as long as people can use it to build valid requests. WSDL fits this criteria but has an extra advantage: you can feed it to a tool that generates code. That code knows how to handle all the SOAP details and exposes objects and methods to your application.
What would you prefer? Generating code from the WSDL in a few minutes and be able to call whatever operation on the web service or, build the requests and parse the responses by hand and spend hours or days doing so. What would your boss or company prefer? :)
It looks to me that the .wsdl file is merely used as a reference to make the correct Post requests. I could just make text templates and plug in the right values, and send them out, right?
Right! But you also have to consider your productivity as an employee in one case as opposed to the other.

Creating and using SOAP based web service in Laravel framework

In Laravel 4 framework, how to create a SOAP based web service. I would like to build a SOA based web application in laravel. Please clarify with an example how to use web service with some step by step examples or links as i am completely new to laravel
Thanks in advance..
You can use "php-wsdl-creator" (also supports SOAP). They have a great tutorial and many demo php files to get you started. It can also easily be implemented in laravel or any other framework for that matter. :)
You can find more information on Google Code: https://code.google.com/p/php-wsdl-creator/
Also note that SOAP requires an extension to be loaded in PHP.
For more recent needs, you should use a Project such as wsdl2phpgenerator or PackageGenerator from WsdlToPhp. This sort of projects, requirable with composer, use an OOP approach and allows to build a SOAP request easily with PHP objects then handle the response just as the request with PHP objects.

Is there a way to extract data from Nagios as if it was a web service?

My situation: I'm working on a web monitoring dashboard that assembles informations from different applications and sources and generate graphs, info graphics and reports.
The applications I'm trying to integrate are CACTI, Nagios, and other local private monitoring tools. I had no problem to integrate these applications, except for Nagios (I don't have much experience with it).
What I want to know is if there is a way to use Nagios as a Web Service, or something similar, so I can expose some of the informations and use it to generate my own reports on my dashboard application.
Is it possible to do that without any epic effort?
thanks for reading.
Nagios 4.x starting with version 4.4 now includes CGIs for JSON output. Installing the newest version of Nagios might be the easiest way to go.
See the announcement here.
Review the slides from Nagios World Conference 2013 here.
The Check_MK Multisite GUI (Web base GUI using MK Livestatus) offers a web service mode, where you can send queries/commands as URL parameters and get the response as JSON in the body.
The trick is: Create a view in the GUI, which fits your needs. Then extract the URL of that view and add the parameter output_format=json. Now you should have the output in a parsable format.
For example, this URL should give you a JSON list of all services:
check_mk/view.py?view_name=allservices&output_format=json
You can try:
1) MK Livestatus http://mathias-kettner.de/checkmk_livestatus.html
it's not web service but it can give current data without any complicated action. All you need redirect this data.
2)status-json plugin http://exchange.nagios.org/directory/Addons/APIs/JSON/status-2Djson/details which return data in JSON format.
3)NagiosWS plugin but I wasn't able to get to work it yet. I think it can be done for Nagios 2.x
4)GroundWork Foundation plugin. I think I will try use it now.
I was able to get to work 1 and 2 solution now.
Otherwise you can use Icinga which can give you some JSON or XML output. Icinga is fork of Nagios and can be installed with saving all your nagios data and plugins. At least it written on Icinga's site =) They have some other solution like PHP lib.
Sorry, I cannot post only 2 link while I'm newbie on this site.
Best regards.
Worked for me - MK Livestatus http://mathias-kettner.de/checkmk_livestatus.html it's not web service but it can give current data without any complicated action. All you need redirect this data.

Could I upload a file through a web service?

I want my customers to upload some file to my server. My current design is as below:
I make a folder on my server with R/W permission to Anonymous user like this: http://myserver/uploads
Customer contact my web service to indicate they want to upload something, and the webservice returned a path like this: http://myserver/uploads/xxx-xxx-xxx-xxx, the xxx part is a GUID.
But I don't know what to do next? I believe customer has the permission to write to the virtual path returned by the web service, but how could I write my client-side code so that it can actually copy things to that virtual path? My client-side is a Win32 application, not a web page.
What if I want the customer upload files within a web page, how to do that? I know that there's a "PUT" method in HTTP protocol that could be used to upload things to server, but how to use that?
I am new to this kind of web development. I hope I made myself clear. If there's any better design, please let me know.
Many many thanks.
Update - 1 - 0:59 2010/12/27
A similar question: How to upload a file to a WCF Service?
Some possible solutions:
Image Upload Web Service in C#.NET
Upload any type of File through a C# Web Service
Progress Indication while Uploading/Downloading Files using WCF
I would avoid allowing anyone to write files to a directory. I know you have set up permissions to help guard against anything bad happening, but it is still setup to where anyone can read/write to it, not just to person you've told the URL to. Security through obscurity is not a best practice.
What kind of webservice are you using? WCF, SOAP, something else all together? I would have the file upload still be a service call (not just some PUT command to a directory). That way you can still apply security if needed. When you get right down to it, a file is nothing more than an array of bytes, so you can have your web service accept an array of bytes and write it out to the correct location. If I had a better idea of what technologies you are using (php, asp.net, jsp, etc) Then I might be able to make more precise recommendations.
HTH
You can use SOAP attachments, or if not using SOAP, something similar - specifying filename, content type and binary data, Base64-encoded.