Working on a project where I need to consume a web service over HTTPS (SSL) using Domino 8.0.2.
Was able to create the script library to consume the web service.
Created a simple button to test consuming it with this code:
Use "AA-FEED"
Sub Click(Source As Button)
Dim ws1 As New IAccountService_n1
Dim r1 As New ArrayOfValidSystem_n2
Set r1 = ws1.GetValidSystemsList()
End Sub
When called, Notes prompts for me to Cross Certify with your server, which I do.
That is to be expected.
Click on 'Cross Certify" button and then the web service is contacted and returns an error message:
"The Web Service IAccountService_n1 method GetValidSystemsList has returned a fault."
So...
The provider of the web serivce says when it is consumed in Java, they add certifier information to the soap header.
Not sure if the Cross Certify actions in Lotus would do equlivent in LotusScript.
If the WebService requires authentication, in your generated web service consumer code, add the following after the webservice initialize call:
Sub NEW
Call Service.Initialize ("UrnDefaultNamespaceWSQueryService", ...
'ADD THE FOLLOWING
'set userid and password if required
Call Service.SetCredentials("userid","password")
'set SSL options
Call Service.SetSSLOptions(NOTES_SSL_ACCEPT_SITE_CERTS + NOTES_SSL_ACCEPT_EXPIRED_CERTS)
Web services in LotusScript has a Java component to it when communicating (uses AXIS).
It might be that you have to put the certificate into the CACERTS. The following wiki article explains this.
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Connecting_to_a_Domino_server_over_SSL_in_Java_using_a_self_signed_certificate._
Related
I need to develop a minimalistic webservice.
It should have 2 functions:
senduserdata (a remote app will call "senduserdata" to send info about users, like "ID" and "amount")
sendconfirmation (a remote app will tell "all ok for proccess ID=X, notes are: NOTES)
In past I did a SOAP dll that needs IIS to run, since deployment is crucial in my case and IIS is not always available is it possible to have a standalone exe that exposes the SOAP (or REST) interface?
I succeded in a few minutes using the RemObjects trial and setting SOAP as communication protocol in a server + client project group (note: i need server only).
With a VCL EXE i can deploy much easier (i have lots of customers, and accessing their IIS to install a dll it is sometimes too hard).
Yes, you can use any TCP library for Delphi which includes a HTTP server, for example Internet Direct (Indy). With Indy, you can create a stand-alone application (or better, a windows service) without IIS.
In a RESTful web application, the senduserdata command would be implemented by a URL like
http://example.com/api/users
The clients then use a HTTP PUT or PATCH request to update the users resource.
A senduserdate call for user id 774422 would be written like
LStream := TStringStream.Create('{ "amount":100.50, "currency":"EUR" }');
try
HTTP := TIdHTTP.Create;
try
HTTP.Put('http://example.com/api/users/774422', LStream);
finally
HTTP.Free;
end;
finally
LStream.Free;
end;
In the the Delphi application for server side, a TIdHTTPServer component then listens for HTTP requests for the /rest/users resource and in the OnCommandOther event handler it would extract the request body string, parse it, and apply the changes to the user with the ID given in the resource path (/774422).
I was trying to deploy a back-end web service to IBM Message Broker. Then create a Java client to call Broker, which in turn calls the back-end web service.
If the Java client can call Broker, then so can any other Java app.
The IBM documentation on the subject is massive. So here are the steps that I took, plus a couple of issues I struggled with, and then resolved.
Two useful links:
Setting up a flow:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r1m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fad64230_.htm
Deploying a flow:
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Faa40160_.htm
Create a new Application.
Within the Application, create a new Message Flow.
On the flow workspace, on the left menu column, select Web Services.
Select a SOAPInput, SOAPRequest, SOAPReply.
Connect the input to the request, and the output of the request to the reply.
When you double-click on the Request, it will be looking for a WSDL. Select import/create new at the bottom of the window. On the next window, select the bottom option to select a WSDL from outside the environment. Paste in the entire URL to your back-end web service.
Click next and finish on the following windows to get back to the Flow work space.
One point that I struggled with and was not obvious in the documentation, is that you will need to create a new flow for each method in your back-end web service.
In the SOAPRequest properties, set the "binding operation" to the method behind that flow.
Once you build and deploy the bar, you can right-click anywhere on the Flow work space and select Test...
The test tool will display the WSDL of the web service that is deployed to your Broker instance. You can grab that WSDL and use Ant or Maven to create a Java client and call your web service (which in turn calls the back-end service)
That's not strictly speaking true, you can route to a label based on the operation name in the wsdl or even use the SOAPInput node in generic gateway mode. Generally you'll want a flow per "service" not per method.
I have two servlets that access two corresponding Axis2 web services on the same host. One of the servlets is read-only, while the other writes to a database.
Each of the Axis2 web services uses BASIC authentication. The read-only web service uses a system account, while the write web service uses the user's credentials (which are submitted as part of a web form).
The problem I'm running into is that the servlet called second always fails authentication to its web service. For example, I can query the read-only service through it's servlet all I want, but I get a "401: Authorization Required" when I try to use the write service. If I call the write service first, I get the same error when I try to use the read-only service.
Here is how I am setting the credentials for the connections in the servlets:
Stub service = new Stub(serviceUrl);
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setUsername(username);
auth.setPassword(password);
auth.setPreemptiveAuthentication(true);
service._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, auth);
The servlet that accesses the read-only service has this code in it's constructor. The servlet that accesses the write service has this code in it's doGet/doPost method.
It seems that the credentials for the first service called are getting cached somewhere, but I can't find where that could be. I saw a possible solution here, but I can't find where WSClientConstants.CACHED_HTTP_STATE is defined. The comments in this JIRA issue seems to imply that it's part of org.apache.axis2.transport.http.HTTPConstants but it's not there.
Specifics:
Axis version: 1.5.1
Tomcat Version: 6.0.26
Java version: 1.6.0_23
It turns out the connections to the two different services were using the same JSESSIONID. Thus, the connection to the second web service was trying to use a session authenticated for the first web service, causing the error.
My solution for this was to define an HttpClient for each service, done by the following
MultiThreadedHttpConnectionManager manager = new MuliThreadedHttpConnectionManager();
HttpClient client = new HttpClient(manager);
ConfigurationContext context = ConfigurationContextFactory.createDefaultConfigurationContext();
context.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, client);
context.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, true);
Stub service = new Stub(context, serviceUrl);
This allows both servlets to have a separate session for their corresponding services.
The important point is to create a dedicated ConfigurationContext.
I've solved in a simpler way using a default config context when creating the stub without the multithreaded connection factory
stub = new MyStub(ConfigurationContextFactory.createDefaultConfigurationContext(), myServicesUrl);
I work with JAX-WS Web services deployed on to a Glassfish Web server and Netbeans IDE. We have provisions to disable or undeploy a Web service deployed onto a Glassfish Web server using admin console or services tab in the IDE. This looks to be some sort of hardware interrupt. I would like to achieve the same, i.e. disabling a deployed Web service through Java code, on some external command from interface. Is there any mechanism to obtain such outcome through software interrupts or by any other means?
You can keep configuration settings like discoveryAllowed attribute at server side may be like in DB.
On which you can decide whether to allow user to call web-methods. Add beelow code in web-method:
If discoveryAllowed is false then call following code:
MessageContext mc = context.getMessageContext();
HttpServletResponse resp = (HttpServletResponse) mc.get(MessageContext.SERVLET_RESPONSE);
resp.setContentType("text/plain");
resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Web service is disabled.");
If discoveryAllowed is true allow to proceed with code execution.
I'm developing an application that includs a web service, on development time I run the service locally on my pc, than I publish the service to a remote server,
I wanna know how can I take the web reference that I got and just change the address of the service to the remote server to check that every thing is ok
You can set the service URL usign the Url property:
MyWebService.Service1 service = new MyWebService.Service1();
service.Url = NEWSERVICEURL;
Right click on your Web reference, click properties, and choose Url behavior: Dynamic in properies window. The URL of the Web service will be automatically mapped to a configuration option in the Web.config file that you can change easily, without recompilation: