WebService::E4SE - Communicate with the various Epicor E4SE web services.
Epicor's http://www.epicor.com/Products/Pages/E4SE.aspx E4SE software uses a clunky, IE-only interface (just try to fill in your timesheet with a non-windows machine! I dare ya!).
Each action on the software calls a SOAP-based web service API method. However, the APIs are not neatly packaged in one place (a la Salesforce, etc.). Also, there aren't any sessions. So, each call to the API must send username and password credentials all over again (using NTLM).
There are more than 100 web service files you could work with (.asmx extensions) each having their own set of methods. Some of these are grouped somewhat logically, some are not. On your installation of E4SE, you can get a listing of method calls available by visiting one of those files directly (http://epicor/e4se/Resource.asmx for example).
The purpose of this module is to somewhat abstract out the tedium of dealing with all of this stuff.
The module will grab the WSDL from the file you're trying to deal with. It will make use of that WSDL with XML::Compile::WSDL11. You can force a reload of the WSDL at any time. So, we build the XML::Compile::WSDL11 object and hold onto it for any further calls to that file. These are generated by the calls you make, so hopefully we don't kill you with too many objects. You can work directly with the new XML::Compile::WSDL11 object if you like, or use the abstracted out methods listed below.
Here's some sample code:
use WebService::E4SE; # create a new object my $ws = WebService::E4SE->new( username => 'AD\username', # NTLM authentication password => 'A password', # NTLM authentication realm => '', # LWP::UserAgent and Authen::NTLM site => 'epicor:80', # LWP::UserAgent and Authen::NTLM base_url => URL->new('http://epicor/e4se'), # LWP::UserAgent and Authen::NTLM timeout => 30, # LWP::UserAgent ); # get an array ref of web service APIs to communicate with my $res = $ws->files(); say Dumper $res; # returns a list of method names for the file you wanted to know about. my @operations = $ws->operations('Resource.asmx'); say Dumper @operations; # call a method and pass some named parameters to it my ($res,$trace) = $ws->call('Resource.asmx','GetResourceForUserID', userID=>'someuser'); # give me the XML::Compile::WSDL11 object my $wsdl = $ws->get_object('Resource.asmx'); #returns the usable XML::Compile::WSDL11 object
The constructor will give you a new WebService::E4SE object. The parameters passed to it are all listed below. They have defaults and since this is a Moose object, you can set each one individually as well with $ws->param_name($foo).
Default is an empty string. Usually, you need to prefix this with the domain your E4SE installation is using. 'AD\myusername'
Default is an empty string. This will be your domain password. No attempt to hide this is made as E4SE cannot function over SSL anyway, why should I bother trying to make you feel secure when you're not.
Default is an empty string. Again, this is for the Authen::NTLM module and can generally be left blank.
Default is 'epicor:80'. This is for the Authen::NTLM module. Set this accordingly
Default is 30. This is passed to LWP::UserAgent to handle how long you want to wait on responses.
This method will return a reference to an array file names that this web service has knowledge of for an E4SE installation.
my $files = $ws->files; # 'ActionCall.asmx', 'Company.asmx', 'Resource.asmx', etc....
This method will call an API method for the file you want. It will return 0 and warn on errors outside of XML::Compile::WSDL11's knowledge, otherwise it's just a little wrapper around XML::Compile::WSDL11->call();
Another way to do this would be $ws->get_object('Reource.asmx')->call( $function, %params );
This is the string name of the file (also the WSDL11 object) you wish to deal with. 'Resource.asmx' for example.
This is the string name of the function you want to call in the file's API. 'GetResourceForUserID' for xample.
This is a hash of name => value pairs to be passed in for the function call. This is XML escaped properly by XML::Compile::WSDL11.
This method will return an XML::Compile::WSDL11 object for the string file name you supply. This handles going to the file's WSDL URL, grabbing that URL with LWP::UserAgent and Authen::NTLM, and using that WSDL response to setup a new XML::Compile::WSDL11 object. Note that if you have previously setup a XML::Compile::WSDL object for that file name, it will just return that object rather than going to the server and requesting a new WSDL.
This property is defaulted to false (0). If set to true, the next call to a method that would require a XML::Compile::WSDL11 object will go out to the server and re-grab the WSDL and re-setup that WSDL object no matter if we have already generated it or not. The property will be reset to false directly after the next WSDL object setup.
Chase Whitener << <cwhitener at gmail.com> >>
Please report any bugs or feature requests to
bug-webservice-e4se at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WebService-E4SE. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Copyright 2013 Chase Whitener.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.