Connect Aras Innovator12 with Java web Application issue

Hello Guys,

I want to connect Aras Innovator 12 With my Java web Application is not work. when I try connect Aras Innovator 11 with  my Java web Application is work. I am using same code in case of Aras Innovator 11 and 12 . Why I am getting Strange behavior   . I do not know.

Please help me . code is below and Exception is below.

httpConnection: Exception :======java.io.IOException: Server returned HTTP response code: 401 for URL: win-8dg8qc6q2gp:80/.../InnovatorServer.aspx

import java.io.IOException;
import javax.servlet.ServletException;
//import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.nio.charset.Charset;
import java.io.ByteArrayInputStream;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.MimeHeaders;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPMessage;
import org.w3c.dom.NodeList;

/**
* Servlet implementation class ArasInnovatorLogin
*/
//@WebServlet("/ArasInnovatorLogin")
public class ArasInnovatorLogin extends HttpServlet {
private static final long serialVersionUID = 1L;
String ErrString="",invalideDb="",ErrorUi="";
java.io.BufferedReader in;
String database="",userName="",innovatorServer="",request="",password="";
NodeList list=null;
boolean isSuccess = false; NodeList returnList;NodeList innerResultList;

/**
* @see HttpServlet#HttpServlet()
*/
public ArasInnovatorLogin() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
try{
Vector getItem=null;
ErrString="<SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../'><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:af='www.aras.com/.../faultcode><faultstring><![CDATA[Authentication failed for admin]]></faultstring><detail><af:legacy_detail><![CDATA[Authentication failed for admin]]></af:legacy_detail><af:exception message='Authentication failed for admin' type='Aras.Server.Core.InnovatorServerException' /></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>";
invalideDb="<SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../'><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:af='www.aras.com/.../faultcode><faultstring><![CDATA[The Database is not available.]]></faultstring><detail><af:legacy_detail><![CDATA[The Database is not available.]]></af:legacy_detail><af:exception message='The Database is not available.' type='Aras.Server.Core.InnovatorServerException' /></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>";
ErrorUi="<SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../'><SOAP-ENV:Body><SOAP-ENV:Fault xmlns:af='www.aras.com/.../af:legacy_detail><af:exception message='formation' type='Aras.Server.Core.InnovatorServerException' /></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>";
this.innovatorServer ="">win-8dg8qc6q2gp:80/.../InnovatorServer.aspx";
this.database ="Netradyne";
this.userName =request.getParameter("UserName");
this.password =request.getParameter("password");
response.getWriter().println("userName:" +userName);
response.getWriter().println("password:" +password);

this.request = "<AML>"
+"<Item type='User' action='get' select='user_name,password'>"+
"</Item>"+
"</AML>";
String formation="Authentication failed for"+" "+this.password;
String nameSpace = "">http://www.aras-corp.com/";
String remoteMethod = "ApplyAML";
String characterEncoding = "UTF-8";
String SOAPmessage = "<SOAP-ENV:Envelope xmlns:SOAP-ENV='schemas.xmlsoap.org/.../' encodingStyle='">schemas.xmlsoap.org/.../encoding'>"
"<SOAP-ENV:Body>"+
"<"+remoteMethod+" xmlns:m='"+nameSpace+"'>" + this.request + "</"+remoteMethod+">"+
"</SOAP-ENV:Body>"+
"</SOAP-ENV:Envelope>";
// Create new URL object and HttpURLConnection object
java.net.URL url = new java.net.URL(innovatorServer);
java.net.HttpURLConnection httpConnection = (java.net.HttpURLConnection) url.openConnection();
// Convert the message to a byte array
byte[] messageBytes = SOAPmessage.getBytes();
//response.getWriter().println(messageBytes);
// Set headers
httpConnection.setRequestProperty("Content-Length", String.valueOf(messageBytes.length));
httpConnection.setRequestProperty("Content-Type","text/xml; charset=" + characterEncoding + "\"");
httpConnection.setRequestProperty("SOAPAction", remoteMethod);
httpConnection.setRequestMethod("POST");
httpConnection.setRequestProperty("AUTHUSER",this.userName);

httpConnection.setRequestProperty("AUTHPASSWORD", MD5(this.password));

httpConnection.setRequestProperty("DATABASE",this.database);
httpConnection.setDoInput(true);
httpConnection.setDoOutput(true);
// Write and send the SOAP message
java.io.OutputStream out = httpConnection.getOutputStream();
response.getWriter().println("httpConnection:" +out);
out.write(messageBytes);
out.close();
// Read server response

in = new java.io.BufferedReader(new java.io.InputStreamReader(httpConnection.getInputStream()));
String inputLine; String erroS="";
while ((inputLine = in.readLine()) != null) {
erroS=inputLine;
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage(new MimeHeaders(),new ByteArrayInputStream(inputLine.getBytes(Charset.forName("UTF-8"))));

SOAPBody body = message.getSOAPBody();
NodeList returnList = body.getElementsByTagName("Item");
isSuccess = false;
response.getWriter().println(in.readLine());
for (int k = 0; k < returnList.getLength(); k++) {

NodeList innerResultList = returnList.item(k).getChildNodes();
response.getWriter().println("innerResultList.getLength()="+innerResultList.getLength());
for (int l= 0; l < innerResultList.getLength(); l++) {

isSuccess=true;
String or="'";
char nr='"';
String Nr=String.valueOf(nr);

//erroS.replaceAll(or,Nr);
//response.getWriter().println(erroS.replaceAll(Nr,or));
//response.getWriter().println(ErrorUi.replaceAll("formation",formation));

int flag=1,Flag=0;
if( ErrString.equals(erroS.replaceAll(Nr,or)))
{
flag=0;
Flag=1;
response.getWriter().println(password+" is not valide Password");


}
if(invalideDb.equals(erroS.replaceAll(Nr,or)))
{
flag=0;
response.getWriter().println("Authantication is fail for the Selected DataBase"+" "+""+database);

}

if(ErrorUi.replaceAll("formation",formation).equals(erroS.replaceAll(Nr,or)))
{
flag=0;
if(Flag!=1)
response.getWriter().println(userName+" "+" is not valide user");
}
if(flag==1)

{

}

// getItem=new Vector();
if (isSuccess) {
list = body.getElementsByTagName("Item");
response.getWriter().println("isSuccess==="+isSuccess);

}
}

}

}
}
catch (Exception e) {
// TODO Auto-generated catch block
response.getWriter().println("Exception :======"+e);
e.printStackTrace();
}
doGet(request, response);
}
public static String MD5(String s) throws Exception{
java.security.MessageDigest m = java.security.MessageDigest.getInstance("MD5");
m.update(s.getBytes(),0,s.length());
return new java.math.BigInteger(1,m.digest()).toString(16);
}

}

Thanks in Advance

Parents
  • It is a 401 error which means that the un authorization of the client by the server. Clear the browser cache and check the URL.

    Are you sure the namespace variable has correct URL ? the username and password are passed correctly?

    Thanks

    Ambuj

  • オフライン in reply to Ambuj

    Yes Ambuj  namespace variable has correct URL (http://win-8dg8qc6q2gp/InnovatorServer/Server/InnovatorServer.aspx) and user name =admin ,Password=innovator , database= Netradyne

    Innovator config details are below

    <?xml version="1.0" encoding="UTF-8"?>

    -<Innovator>

    <UI-Tailoring product_name="Aras Innovator"/>

    <operating_parameter value="false" key="debug_log_flag"/>

    <operating_parameter value="10000" key="debug_log_limit"/>

    <operating_parameter value="true" key="debug_log_pretty"/>

    <disabled_operating_parameter value="cpu" key="performance_logging"/>

    <operating_parameter value="false" key="xslt_processor_debug"/>

    <disabled_operating_parameter value="file" key="email_debug_option"/>

    <License company="" act_key="86E55A20804D404EA25FCCEFB41096A2" lic_key="973816472a1fd3a7beb6c3139d611360" lic_type="Unlimited"/>

    <Mail SMTPServer="127.0.0.1"/>

    <operating_parameter value="C:\Program Files (x86)\Aras\Innovator\Innovator\Server\temp\" key="temp_folder"/>

    <operating_parameter value="C:\Program Files (x86)\Aras\Innovator\Innovator\Server\dll\" key="ServerMethodTempDir"/>

    <operating_parameter value="C:\Program Files (x86)\Aras\Innovator\Innovator\Server\logs\" key="debug_log_prefix"/>

    <AgentService InnovatorToServiceAddress="">localhost:8734/.../>


    -<OAuthServerDiscovery>


    -<Urls>

    <Url value="$[HTTP_PREFIX_SERVER]$[HTTP_HOST_SERVER]$[HTTP_PORT_SERVER]$[HTTP_PATH_SERVER]/OAuthServer/"/>

    </Urls>

    </OAuthServerDiscovery>

    <DB-Connection dbo_pwd="innovator" dbo_uid="innovator" regular_pwd="" regular_uid="innovator_regular" server="(local)\SQLEXPRESS" database="Netradyne" id="Netradyne"/>

    <DB-Connection dbo_pwd="innovator" dbo_uid="innovator" regular_pwd="" regular_uid="innovator_regular" server="(local)\SQLEXPRESS" database="NetradyneTestDB" id="NetradyneTestDB"/>

    </Innovator>

    I am try to access  URL(http://win-8dg8qc6q2gp/InnovatorServer/Server/) getting error.

    I am to login with url(http://win-8dg8qc6q2gp/InnovatorServer/Client/) able to lgin

  • オフライン in reply to Ashok.Yadav

    Hi Ashok

    Check with your server administrator.

    From the image that you have attached it is clear that the URL (http://win-8dg8qc6q2gp/InnovatorServer/Server/ ) is not correct and the request is not validated.

    Thanks,

    Ambuj

Reply Children
No Data