Weblogic - Testing SOAP Web Service With Test Client - web-services

I have created a PL/SQL SOAP Web Service using the Web Services Wizard in JDeveloper 11g. I am able to successfully deploy it on the Integrated Weblogic Server. After which I am able to launch the Weblogic Test Client in a browser.
I then deployed the web service to an EAR using the Deployment Profile , created for the web service application (using Jdeveloper). Used this EAR to deploy the service to a remote dev weblogic managed server (NOTE: I am using Weblogic 10.3.5.0).
Deployment was successful and I was able to start the application too. The state of the deployment is "Active" and the is health "OK" . I am able to see the dynamic WSDL for the my web service too.
Here is where i am having issues. I am unable to test the web service by using the Weblogic Test Client. I am getting the 404 Not Found error when i click on the web service test point.
Has anyone had the same issue with launching the test client ?
Appreciate your comments / suggestions !!!

Make yourself a test soap script:
<?php
if(isset($_POST['request'])){
$XML = $_POST['request'];
$URL = $_POST['url'];
$ch = curl_init("$URL");
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$XML);
$result=curl_exec ($ch);
curl_close($ch);
}
?>
<form method="post" style="margin: 0; padding: 0;">
<input name='url' type="text" placeholder="URL here" value="<?php if(isset($_POST['url'])) echo $_POST['url']; ?>" style="height: 10%; width:90%">
<button style="width: 10%; height: 10%;">LOAD SOAP</button><br />
<textarea style="width: 50%; height:90%;" placeholder='REQUEST HERE' name="request"><?php if(isset($_POST['request'])) echo $_POST['request']; ?></textarea>
<textarea placeholder="RESPONSE HERE" disabled="true" style="width: 50%; height:90%;"><?php if(isset($result)) echo $result; ?></textarea>
</form>

Related

ASP.Net MVC web application Impersonated doesn't react the same way out of the server

I have developed an asp.net mvc 5 web application that works with impersonation. I'm using Impersonation because my web app is calling Navision Dynamics web services and I don't want the users to enter the credentials.
I have deployed my web application on a Windows Server 2012 R2 with IIS 8.5.
I have changed the application pool to .NET 4.5 Classic with a Classic Pipeline mode and I have activated the impersonation authentication.
My web application works well while I navigate it form the Server Internet Explorer but raise me an “System.Data.Services.Client.DataServiceClientException: Forbidden” error when I try to access it from another computer.
If I stay on the server and change localhost to myServerName in the URL, I don't get any error but I don't receive my data from Navision.
Here is my System web configuration
<system.web>
<compilation targetFramework="4.5.1" />
<httpRuntime targetFramework="4.5.1" />
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<customErrors mode="Off" />
<identity impersonate="true" />
</system.web>
Here is the way I Consume My Navision Service
using System.Linq;
using System.Net;
using System.ServiceModel;
using System.Web;
namespace MyWebApplication.Models
{
public class Matter
{
public string Matter_No { get; set; }
public string Matter_Label { get; set; }
}
public static class MatterDataContext
{
[OperationBehavior(Impersonation = ImpersonationOption.Required)]
public static IEnumerable<Matter> GetMatters()
{
List<Matter> matterLines = new List<Matter>();
Uri uri = new Uri(ConfigurationManager.AppSettings["NavisionODataUri"]);
var NAV = new NavServiceRef.NAV(uri);
NAV.Credentials = CredentialCache.DefaultNetworkCredentials;
var resultMatterLines = from m in NAV.matterlist
select m;
foreach (var m in resultMatterLines)
{
Matter ligne = new Matter();
ligne.Matter_No = m.Matter_No;
ligne.Matter_Label = m.Matter_Label;
matterLines.Add(ligne);
}
return matterLines;
}
}
}
I have added this peace of code to my index for debug
<table border="1">
<tr>
<td>Application code executed using</td>
<td>#System.Security.Principal.WindowsIdentity.GetCurrent().Name</td>
</tr>
<tr>
<td>Is user authenticated</td>
<td>#User.Identity.IsAuthenticated</td>
</tr>
<tr>
<td>Authentication type, if authenticated</td>
<td>#User.Identity.AuthenticationType</td>
</tr>
<tr>
<td>User name, if authenticated</td>
<td>#User.Identity.Name</td>
</tr>
</table>
and I receive what I was expecting :
Application code executed using: DOMAIN\jeremy
Is user authenticated: True
Authentication type, if authenticated: NTLM
User name, if authenticated: DOMAIN\jeremy
I can't find what I'm doing wrong...
Can someone help me please?
you need to do the following :
- verify that you installed both
ASP.NET and windows authentication on IIS
- once installed , from IIS authentication verify that you enabled windows Authentication and impersonation and disabled anonymous access

Encoding of spaces in POJO parameters in Axis2

I have created a very simple service that just echos some text to the console. The service is just a POJO with a method echo, having a single parameter:
public class EchoTest
{
public void echo(String myMessage)
{
System.out.println(myMessage);
}
}
Ths is from the services.xml:
<service name="EchoTest">
<description>Echo test</description>
<parameter name="ServiceClass">EchoTest</parameter>
<operation name="echo">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>
Further I use a very simple HTML form to submit the data to the service:
<html>
<body>
<form method="post" target="responseFrame" action="../../services/EchoTest/echo">
<input name="myMessage" type="text">
<input value="Send" type="submit"/>
</form>
<iframe width=500 height=500 name="responseFrame"></iframe>
</body>
</html>
The problem I have is that spaces are replaced with '+'. For example, if I type a message like this:
Hey you & you - # % #
The result is this:
Hey+you+&+you+-+#+%+#
Do I have to encode it somehow or or should it not behave like this? Or perhaps it is a setup issue? I am using Tomcat as a web container. For information, I use a servlet filter in Tomcat to e.g. filter on IP addresses, and in there I can see that the myMessage parameter looks OK, not having + signs.
It turns out that the problem was in fact within Axis2 itself. I am not sure exactly, but the version that I was using was release 1.5.1 from October 2009. What bugs me is that I have not found any bug report on it. It could be that it was fixed quickly and that I was unfortunate.
Upgrading to a the latest version of Axis2 solved the problem.

Sitecore send workflow emails

I want to configure Sitecore Workflow engine for email sending.
I had a look into the "Email Action" implementation using Reflector,
It reads "mail server" from argument as follows.
string host = this.GetText(innerItem, "mail server", args);
Don't we need to provide credentials(Username/Password) for mailserver? Or does it take mail configuration from the webconfig?
I have not tried email sending with Workflow yet, Please help me to configure email sending module.
Thanks
Sitecore reads the mailserver settings from the following properties in the web.config:
<setting name="MailServer" value="your.mailserver.com" />
<!-- MAIL SERVER USER
If the SMTP server requires login, enter the user name in this setting
-->
<setting name="MailServerUserName" value="" />
<!-- MAIL SERVER PASSWORD
If the SMTP server requires login, enter the password in this setting
-->
<setting name="MailServerPassword" value="" />
<!-- MAIL SERVER PORT
If the SMTP server requires a custom port number, enter the value in this setting.
The default value is: 25
-->
<setting name="MailServerPort" value="25" />
This should be enough to send emails from Sitecore and webforms.
Yes. It reads your mail settings from the web.config. In addition to all of the Sitecore mail settings you need to configure you should also add the generic ASP.NET mailSetting at the bottom of your web.config.
<system.net>
<mailSettings>
<smtp>
<network host="127.0.0.1" />
</smtp>
</mailSettings>
</system.net>

How To Return A Graceful Error When Auth Fails For a Custom Web Service

I have a web service up and running with <cflogin> used for authentication and everything works as expected when you provide a valid username/password. The problem I have is that if authentication fails on the <cfinvoke> side (client) I get a huge error dump of data rather than a graceful error message back from the service (ie: "Bad Username and/or Password. Contact your administrator").
I'm using the cflogin method to secure the web service as described here: help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec13a13-7fe0.html
Here is a snip of the CFDUMP (DUMP.Diagnostics) I get back when I provide a bad username/and-or/password:
Cannot perform web service invocation service_name. The fault returned when invoking the web service operation is:<br> <pre>AxisFault faultCode: {http://xml.apache.org/axis/}HTTP faultSubcode: faultString: (401)Unauthorized faultActor: faultNode: faultDetail: {}:return code: 401 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IIS 7.5 Detailed Error - 401.5 - Unauthorized</title> <style type="text/css"> <!-- body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;background:#CBE1EF;} code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} .config_source code{font-size:.8em;color:#000000;} pre{margin:0;font-size:1.4em;word-wrap:break-word;} ul,ol{margin:10px 0 10px 40px;} ul.first,ol.first{margin-top:5px;} fieldset{padding:0 15px 10px 15px;} .summary-container fieldset{padding-bottom:5px;margin-top:4px;} legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} legend... ''</pre> <br>The error occurred on line 25.
I suspect it has something to do with the snippet below (from the article above) but trying to return a string causes an "premature end of file" error:
<cfif not isAuthorized>
<!--- If the user does not pass a user name/password, return a 401 error.
The browser then prompts the user for a user name/password. --->
<cfheader statuscode="401">
<cfheader name="WWW-Authenticate" value="Basic realm=""Test""">
<cfabort>
</cfif>

How to show custom message when somebody clicks on refresh button of Coldfusion cfGrid (When session is out)?

I am using Coldfusion (9.0.1) cfGrid to populate some data. Code is given below
<cfform id="ViewNewCustomerReport" name="ViewNewCustomerReport">
<div class="buttonClass">
<cfinput type="button" id="generateReport" name="generateReport"
value="Generate Report" />
<cfinput type="hidden" name="filters" id="filters"
bind="javascript:GenerateReport({generateReport#click})"/>
</div>
<br/>
<div id="gridContainer">
<cfgrid name="NewCustomerReport" autoWidth="Yes" colheaderbold="true" selectonload="false" width="710"
bind="url:index.cfm?fuseaction=ReportsCommon.GetNewCustomerReport&page={cfgridpage}&pagesize={cfgridpagesize}&gridsortcolumn={cfgridsortcolumn}&gridsortDirection={cfgridsortdirection}&filter={filters}"
bindOnLoad="false" striperows="true" striperowcolor="##F6F6F6" format="html" pagesize="10">
<cfgridcolumn name="COMPANY_NAME" width="280" header="Company Name" />
<cfgridcolumn name="SUBJECT_ASSIGNED" width="280" header="Subject Assigned" />
<cfgridcolumn name="NO_OF_USERS" header="No. Of users" width="180" />
</cfgrid>
</div>
<div id="wrapperDiv"><label id="lblError" class="CustomError"></label></div>
</cfform>
And this is the javascript part
var GenerateReport = function(filters){
var returnVal;
var checkForm = $('#ViewNewCustomerReport').validationEngine('validate');
returnVal = dateFrom + '|' + dateTo;
if(checkForm)
{
var gridObject = ColdFusion.Grid.getGridObject("NewCustomerReport");
var store = gridObject.getStore();
store.addListener("load",function(){
if(store.data.items == 0)
{
gridObject.setVisible(false);
$("#gridContainer").hide();
$("#wrapperDiv").show();
$("#wrapperDiv").css("text-align","center");
$("#lblError").text("No record found").css({"font-size":"20px","font-weight":"normal"});
}
else
{
gridObject.setVisible(true);
$("#gridContainer").show();
$("#wrapperDiv").hide();
}
});
}
else
{
$('#gridContainer').hide();
}
return returnVal;
};
Now if somebody logout the application in another tab and then refreshes the Grid it show some message like
CFGRID: TOTALROWCOUNT missing from response data [Enable debugging by adding 'cfdebug' to your URL parameters to see more information]
When Session is out in return the Json data collected is like that
{"isSessionOut":true} HTTP Status code 200 HTTP status Message OK
So my Question is instead of showing that default error message i want to show my custom message like session is out please log in to continue.
how can these be achieved ?? Thanks in advance ......
Every bind operation/Ajax call in coldfusion has an OnError/BindError handler function, which can be called at the time of some error, or we can call it with the help of HTTP response by setting the HTTP status code.
Whenever you want some
self generated error message, you can write this code at response/Action page of your site:
error = getpagecontext().getresponse().setstatus(306, "Your session is out");
(you can set HTTP status code any thing more then 300 but i have checked only for 306 and it works)
by this you can call onError function of your CFGRID
I would use a jQuery or similar plugin that runs in the outer page and detects inactivity, then it can even count down when session is timing out and gracefully take your user back to a login page. This way you wont have this issue on any page.
This one is good, there are many others also
jsFiddle