Web services to validate the canadian address through purolator webservice - c#

Hey I am trying to use Purolator Web services to validate the address.
I already included web services in my project and have all credential to communicate but I don't know how to validate through web services and it's my first time that I am using web services please help
I am using C#
I have three input field to asp.net to validate
city
Postcode and
province
If someone can give me details info how to this validation through web service I will really appreciate their help.
Please give some sample code how can I do this
already included reference
using com.purolator.devwebservices;
com.purolator.devwebservices.ValidateCityPostalCodeZipRequestContainer;
This is how it show in their documentation.
I like to upload the picture to show you the web service request and response diagram but I don't have privileges
ValidateCityPostalCodeZipRequestContainer
ValidateCity PostalCodeZipRequest
tns:RequestContainer (extension)
tns:Addresses SenderA ddress - ShortAddress[]
tns:ArrayOfShortAddress
tns:ShortAddress
tns:ShortAddress
tns:City City -string
tns:Province Province - string
tns:Country C ountry - string
tns:PostalCode P ostalC ode; - string

In order to call the webservice, you first have to add a web reference, which you already did, now you need to instantiate the object of proxy class which from your post i believe is ValidateCityPostalCodeZipRequestContainer and call the RequestContainer method of object with required parameter to validate the address.
* Answer above is based on my assumptions becuase I don't have any information about the webservice. If you can post WSDL then I can give a precise answer.
Between, according to Purolator's website there are number of sample available here: https://eship.purolator.com/SITE/en/content/developmentprocess/websservicesprogram.aspx
May be you can find one using asp.net
And by the way there is a nice tutorial given here for consuming webservices in asp.net: Calling Web Service using ASP.NET.

Related

How to expose simple web service using Basic Authentication in ASP.NET

I maintain an ASP.NET Web API project which supports a simple REST end point for clients to post XML data to our server. This site is setup to support BasicAuthentication and works very well. All of our security checks are done at the network firewall and on the machine itself using custom Windows User accounts. Recently, one of our clients requires that we support a SOAP end point to receive the XML data as well.
My thought was to simply add a new WebService (Blah.svc) with supporting interface having the required [ServiceContract] and [OperationContract] attributes to my interface. I had hoped that I could simply expose the URL to our client and it would "just work". I am able to hit the end point, but this service is not able to extract the user name.
Here is my sample code:
public string CreateWorkItem(string xml)
{
var userName = HttpContext.Current.User.Identity.Name;
if (string.IsNullOrEmpty(userName))
userName = "NO USER NAME";
var elem = XElement.Parse(xml);
return $"Hello [{userName}]! You sent [{elem.Value}].";
}
Here are my results:
I've scoured the web to try and find out how to get access to the BasicAuthentication details in a Soap message, but I'm not having any luck. All the examples that I'm finding require that I create a new WCF project and expose it with a lot of web.config settings, or the examples are ~5 years old using older techniques.
I'd like this service to simply publish with my WebAPI project using the Publish... option inside Visual Studio. Unfortunately, I've not found a common denominator to make it work. I'm sure I'm missing something, and I hope someone can help.
Any help would be greatly appreciated!
Check this link out: WCF Services and ASP.NET
In short you need to enable ASP.NET Compatibility in your WCF service.
However, you may want to look into using OperationContext.Current.ServiceSecurityContext.*
The fact that it is HttpContext.Current.User.Identity.Name is returning null means either:
User is null; or
User is Anonymous
I have a few ideas to help resolve the issue.
1. Your User.Name is actually null
You might want to debug by grabbing HttpContext.Current.User and see if it's correct.
2. Go direct: get the cookie via a parameter
Try and pass the HttpContext as a parameter so you can grab the cookie?
public string CreateWorkItem(HttpContext context, string xml)
{
var username = context.Current.User.Identity.Name;
...
}
3. Your configurations are not setup properly
The alternative is that maybe your web.config or Global.asax is not setup to properly.

CRM 2013 Get CRM URL via Custom Workflow

I have a requirement for getting a CRM URL via a custom workflow to use in the next step which is to send an email. The reason for this is to differentiate to users which server this email has come from (UAT/Live).
I have been trying to use HTTPContext route as advised from this site https://social.microsoft.com/Forums/en-US/31ff567d-65ea-4385-a764-68a2121ae8c0/ms-crm-2011-get-path-of-crm-server-url-in-plugin?forum=crmdevelopment but the result I get back is useless as I am I am only receiving an "/" back.
Does anyone know what to do from this point or why this may not be working?
This can't be accomplished, in a supported manner, without creating a connection to the CRM Discovery Service, which requires that you supply credentials. The organization service, available in the workflow does not have a method for discovering the organization's URL.
You have two options:
1) Pass it to the workflow as a parameter using the InputParameter code attribute on your CodeActivity.
2) Create (if you don't already have one) a configuration entity to store the URL and retrieve it in your code.
If you don't really need the URL (i.e., you are not creating a link) then you could just query the Organization entity for the Name attribute. That will give you the Organization's name - which would be the only unique part of the URL. This would allow you to indicate to the user if the Email was coming from UAT or Prod.
I ended up coming up with a solution by using the environment.machinename to pull through the server name. From there i could determine which production server the workflow had been run through and passed a string containing, dev, uat or live to the output to use in my activity emails.
Be aware i had to register the workflow without it being in sandbox mode. Hope this helps somebody in the future.
This was an extremely old question but I came across it while attempting to do something similar.
I found that there is a RetrieveCurrentOrganizationRequest request which was introduced in v9. This will work in sandboxed plugins.
You can use this to retrieve the endpoint urls like so
var currentOrg = base.OrgService.Execute(
new RetrieveCurrentOrganizationRequest()
) as RetrieveCurrentOrganizationResponse;
var url = currentOrg.Detail.Endpoints
.Where(e => e.Key == EndpointType.WebApplication)
.FirstOrDefault()
.Value;
More information here: RetrieveCurrentOrganizationRequest
When I used it, I found that there are 3 available URLs in the Endpoints collection:
Web Application
Organization Data Service
Organization Service
Relevant to CRM 2013 (which the OP was using at the time), there is also the RetrieveOrganizationRequest class which does the same as above; however you have to specify the Organization (and some other information)

Login from Sample with SOAP

I'm trying to connect to the server, but as a function of cobrandLoginService.loginSobrand example for C# there is an exception:
java.lang.NillPointerEsseption
In the settings are correct сobrand login and password, to TestDrive authentication passes.
Web address may be incorrect server? Set this in my profile.
What could be the problem and what information is needed? Thank you.
Are you using SOAP or REST sample?
If SOAP - then make sure that you have all the parameters filled correctly in the APP.config file of the sample provided by Yodlee.
If REST - Then you can call do the cobrand login by make the REST call based on this article

Can I Generate a Password Rest Token in mvc 3?

I have an MVC 3 application, in which I am using actionMailer to send out emails (to the C drive for now) for Password reset etc.
The problem is I can send the e-mail and password reset no problem however there is nothing to stop the user from using that same email over and over again.
So I believe I need to send a token with the e-mail.
I've being trying to use...
var token = WebSecurity.GeneratePasswordResetToken(email);
I get following error...
You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.
UPDATE: Basically I'm looking for the steps involved in doing the above for an MVC 3 application!
I have no webpages tables in my database and would prefer not to have to add such tables now.
I have searched around the web and keep getting answers related to MVC 4, which as far as I can understand as built-in facility for the above.
I have webMatrix.WebData in place in my references folder, and have set "CopyToLocal = true".
If anyone as any advice can you please be as detailed as possible in your suggestions, also I can post up whatever additional code needed. Please keep in mind this is MVC 3 application.

Web API to insert records

I am working on Taleo web API. I have an XML file with several records that I will have to insert into the Taleo system using its web API.
I have got the Taleo API guide from http://tbe.taleo.net/products/TBE_API_Guide.pdf.
For the first time, I am working on web API so I don't know where to start. Although the guide shows some examples using SOAP, I don't know how to make this request and retrieve the response using C# or VB.NET. I googled it but didn't get much information about it. If you share your ideas, I would really appreciate it.
From the PDF, it appears the WSDL for the service is at: http://tbe.taleo.net/wsdl/WebAPI.wsdl. In your C#/VB project, use the "Add Service Reference" option on the context menu and supply that URI to the WSDL. That will generate a proxy and many ancillary classes on which you can call whatever methods you need - the SOAP details are under the covers. You'll instantiate an instance of WebAPIClient and should see all the relevant methods there.
For example, in C# after creating a new Service Reference with (uninspired) namespace name of ServiceReference2, I can code the following (though I have no idea what it does!):
var x = new ServiceReference2.WebAPIClient(); // I suspect there's an overload expecting credentials
ServiceReference2.AccountBean y = x.getAccountById("bar", 0);
Exception handling is left to the reader :)

Categories