change asp.net 2 web service address - web-services

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:

Related

Call external web service with Sencha Cmd application

I created an ExtJS 5 application with Sencha Cmd.
I will deploy this application in a tomcat server where there are some REST web services.
I would need to use these web services but when I run the application with "sencha app watch" (on port 1841) it doesn't find the services because they are on a differente server (tomcat is on a different port).
How can I use an "external" web service with Sencha CMD?
Thanks
stefano
Here are some of the available options:
Option 1 Proxy Web Service
You could create a service on the local machine where the sencha app is that create web requests that then goto the target remote services. This is called a proxy service.
Essentially the proxy service will take a request and resubmit it to the desired target remote machine.
There is a php example here
And a C# web request example here (Although this c# example isn't exactly what you are needing. The base of the web request that would need to be submitted is in this code. )
Option 2 JsonP
The other option off the top, is if the web services on the other machine support jsonp they should be accessible. However, jsonp only supports get so if you have a full rest implementation some services will probably not work.
More information on jsonp
And an extjs request example for JsonP:
Ext.data.JsonP.request({
'url': 'url',
params: {
'param1': 'value'
},
success: function (result, request) {
//success
}
});
Option 3 Hosting multiple apps/paths on single port
However, since it seems like the tomcat server may actually be on the same machine. Is there not a way to host both the web services and the application path through tomcat?
It looks like, for instance, jetty has an option to host two apps on the same port
Option 4 Enable CORS
You can enable cross origin resource sharing on the rest application depending on the architecture/framework used.
The browser will basically send a request first to see if it can access the resource. And then the server would respond with the allowed origin domains. Once CORS is enabled then access could be granted between the two different ports/servers
Great site on CORS with instructions for enabling on most basic setups
Here is example documentation for spring

Identifying dynamic host and port for ATG Web Service created through Create Web Service Wizard

I am using ATG 10.2 with Weblogic server. I have created a Repository web service (getRepositoryItem) using the Web Services Wizard through dyn admin. I left the host and port empty during the EAR creation. My service is up with the EAR now, but according to the documentation for ATG web services, it says the host and port would be provided on run time. I have not provided any security setting for the webservice but it shows me a 403 if I try to hit the context for the servlet for the service.
I am struggling to access the web service. In the Manage Web services through dyn admin I see my WebApp deployed. But its Instance Running and Registered is displayed as false.
Documentation tells that if the service has been executed Instance Running and Registered displays as true.
Could somebody please help in answering, How to access the web service?
You can use the url as follows it will work. I just had to use the name twice.
http://host:port/serviceName/serviceName?WSDL

Calling a back-end web service with IBM Message Broker

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.

Consume SSL Web Service using Domino 8.0.2

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._

How do I setup a asmx web service in Azure that accepts a client certificate?

I apologize in advance if the question is ridiculous.
I have an asmx service running in Azure (HTTP - no SSL).
I have a WPF app that loads a X509Certificate2 and adds it to the request by doing the following:
X509Certificate2 cert = new X509Certificate2("...");
webRequest.ClientCertificates.Add(cert);
In the web service I get the certificate by
new X509Certificate2(this.Context.Request.ClientCertificate.Certificate)
And then I load a cert (that I have both uploaded to the Azure control panel and added to my service definition file) by using the following sample:
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection certs = store.Certificates.Find(X509FindType.FindBySubjectName, certName, true);
And then I validate by doing the following:
clientCert.Thumbprint == certs[0].Thumbprint
Now unfortunately I get an exception (System.Security.Cryptography.CryptographicException: m_safeCertContext is an invalid handle) as soon as I do
Request.ClientCertificate.Certificate
So I have a few questions. How do I avoid the exception. This answer states I need to modify an IIS setting, but how can I do that in Azure?
In any case is this even the proper way to do certificate authentication?
Thanks!
You can use command scripts to modify IIS, in combination with appcmd.exe.
For a quick example (disabling timeout in an application pool), take a look at this sample by Steve Marx.
In this example, you'd call DisableTimeout.cmd as a startup task. For more info on creating startup tasks, you can watch this episode of Cloud Cover Show. There should be a lab on startup tasks in the Platform Training Kit as well.
Just remember that any type of IIS configuration change should be made via an automated task at startup. If you manually change IIS via RDP, those changes won't propagate to all of your instances, and won't remain persistent in the event of hardware failure or OS update.
You can remote into your azure instances to manage IIS. As for a way to do it globally for all instances at once, I'm not sure. That would be an interesting side project though.
http://learn.iis.net/page.aspx/979/managing-iis-on-windows-azure-via-remote-desktop/