Operations on boolean
Hello,
how can have the following with AppleScript :
0110 OR 1001 = 1111 ?
Regards,
Didier.
Bonjour de France
on |0110or1001|(t1, t2)
if (length of t1) = 4 and (length of t2) = 4 then
set r to ""
repeat with i from 1 to 4
if (t1's character i = "1") or (t2's character i is "1") then
set r to r & "1"
else
set r to r & "0"
end if
end repeat
else
set r to "xxxx"
end if
return r
end |0110or1001|
set oo to my |0110or1001|("0110", "1001")
Yvan KOENIG (from FRANCE mardi 3 octobre 2006 17:17:24)
Similar Messages
-
Does bitwise operation on boolean datatypes work like logical operation ?
Does bitwise operation on boolean datatypes work like logical operation ?
For example, in the following code, how is each bitwise operation (say) 'b1 & b2' evaluated ?
1) by converting the values of b1 (true) and b2 (false) to binary and doing '&' on them OR
2) just treating it as a logical operation (i.e. similar to &&) where both have to be equal to be true
Also, does the outcome of the if condition need to result in a 'true' or 'false' for the relevant message to print ? ....... Just fyi, I tried out this program and it goes to condition 2 but I do not understand why.
class SSBool {
public static void main(String[] args) {
boolean b1 = true;
boolean b2 = false;
boolean b3 = true;
if (b1 & b2 | b2 & b3 | b2)
System.out.println ("condition 1");
if (b1 & b2 | b2 & b3 | b2 | b1)
System.out.println ("condition 2");
Thank you,
AGThe Java Tutorial (always my first stop if I need an answer) says :
"When both operands are boolean, the operator & performs the same operation as &&."
That your program goes to condition 2 is obvious because the last test in the if-clause if (b1 & b2 | b2 & b3 | b2 | b1) looks at b1 which is true... -
Assign result of business operation to Boolean
experiencing the following problem.
I have defined a business operation which returns a Boolean.
I have defined a vairable also of type Boolean.
When I use the business operation, the assign result to drop down list
does not contain the Boolean variable I have defined.
regards
jackThis is a known bug that has been fixed. Get the latest WLI service pack,
or better yet, download version 2.1.
Michael
Michael Cincinatus
WLI Product Manager
[email protected]
"jack" <[email protected]> wrote in message
news:3bc5d91c$[email protected]..
>
experiencing the following problem.
I have defined a business operation which returns a Boolean.
I have defined a vairable also of type Boolean.
When I use the business operation, the assign result to drop down list
does not contain the Boolean variable I have defined.
regards
jack -
Operations on very large binary numbers
Hi guys,
I'm trying to write a java class for manipulations of very large binary numbers.
I'm representing the BN internally as boolean[] (array of booleans false for 0 & true for 1).
I want to write an algorithm for the following operations :
shifLeft (boolean[] b,int n) : shifting binary number to left by n positions.preferably a circular shift .
and also the corresponding shiftRight() method.
can some one guide me on how to implement this ?
thanks.Consider an array of ascii chars....
array => | |a|b|c|d|
offset = 1
len = 4In the above there are actually five spots in the
array but the offset points to the second position in
the array and the length is 4.
If I was to extract the value it would be "abcd"
because of the offset and the length.
Now a 'shift right' means that if it is "abcd" then
it should now be "abc" (because the d fell off the
end.)
I can do that like this.
array => | |a|b|c|d|
offset = 1
len = 3Notice in the above that nothing changed except the
length. But because the length changed if I
extracted the value I would get "abc" because the
offset is 1 and the length is three.
Notice also that there was no array copying.Are you sure shifting works like that ?
what I know about left shifting is that the 'd' should be moved left -toghether with a, b, c- and we append a 0 in place of 'd' .
from what you said the 'd' would be gone , or am I again wrong ?
it seems i still didn't get any satisfactory answer to this problem... -
If a and b contain a number each, what should
if(a>0&&b6=0)be?= --> assignment operator
example:
a = 0;
a = a + 1
// a now equals 1; it doesn't solve the algebraic equation or anything
== --> comparison operator, returns boolean value
example:
if(a == 0)
// do something
Now you can correct it.
theAmerican -
Boolean | vs Logical ||?
First of all, I know this won't work for bitwise |.
But, this code:
boolean a=false, b=true, c;
c = a|b; // c is now true
c = a||b; // c is now also true
Is it just a remnant from the C-style language, or what?
Are boolean | and logical || optimized differently?
Conditions in Java can only evaluate to boolean values, so things like this
if ((a == false) | (b == false))
works just as well as
if ((a == false) || (b == false))
I'd say it's bad style to use || for boolean (as in c=a||b;), but does it really matter?
-- Tino Didriksen, [email protected]| is a bitwise OR that operates on integral types (char, short, int, long), and apparently, boolean.
|| is a boolean or logical OR that operates on boolean.
| evaluates to an integral values (I don't know if it's int or the larger of the operand types, or what).
A || B can short circuit because the truth of the entire statement is known if A is true.
x | y cannot, in general, short circuit, because it's a bitwise or--that is, you have to examine each bit. Now you COULD examine only those bits of y for which the corresponding x bit was 0, and then if x was all 1s, not examine y at all. However, Java doesn't work this way, AFAIK--it just operates on all values as the general case--examining both operands.
It's been put forth that the difference between | and || is that | doesn't short circuit and || does. I would say that's a side effect. The real fundamental difference is that | does bitwise operations on integral operands to produce an integral result, whereas || does a boolean operation on boolean operands to produce a boolean result.
The comparisons using true/false stem from the fact that, for | (and I assume &), boolean expressions (e.g. true/false) seem to be treated as single bit integral types. However, in the general case, boolean and integral types are not interchangeable in Java, and the issues of short circuit vs. not doesn't apply, since the two operators do different things and operate on different types. -
Why does DataOutputStream write Boolean as 1 Byte?
Im trying to conserve space in a file storing booleans.
why does dataoutputstream write booleans as a byte?
is there a way to write a bit only?
thanks!Hi,
A boolean does even allocate at least 8 bits when it is declared in the code.
From the VM spec:
"3.2.4 There Is No boolean Type
Although Java defines a boolean type, the Java Virtual Machine does not
have instructions dedicated to operations on boolean values. Instead, a
Java expression that operates on boolean values is compiled to use the int
data type to represent boolean variables.
Although the Java Virtual Machine has support for the creation of arrays of
type boolean (see the description of the newarray instruction), it does not
have dedicated support for accessing and modifying elements of boolean
arrays. Arrays of type boolean are accessed and modified using the byte
array instructions.1
For more information on the treatment of boolean values in the Java Virtual
Machine, see Chapter 7, "Compiling for the Java Virtual Machine.""http://java.sun.com/docs/books/vmspec/html/Overview.doc.html#22909
/Kaj -
hi all,
Can anyone tell me, how many bytes are taken by a boolean variable.
Pls support ur answer.
Also let me know, Is there any method in java to calculate the size of
a particular datatype, like sizeof() in c/c++.
Thanks in advance.Refer the following link
http://www.cafeaulait.org/course/week2/02.html
Yes, that website mentions 1 bit but as I said other
sites mention other sizes. Just because you found it
on that website doesn't mean it is true. Only the
good people at sun know the truth.Ok, I will quote the VM specification which you have to adhere to if you implement a VM. As I said previously: The size is not specified in the JLS, but in the VM specification and you will not have a compatible VM if you aren't following it.:
http://java.sun.com/docs/books/vmspec/2nd-edition/html/Overview.doc.html
"3.3.4 The boolean Type
Although the Java virtual machine defines a boolean type, it only provides very limited support for it. There are no Java virtual machine instructions solely dedicated to operations on boolean values. Instead, expressions in the Java programming language that operate on boolean values are compiled to use values of the Java virtual machine int data type.
The Java virtual machine does directly support boolean arrays. Its newarray instruction enables creation of boolean arrays. Arrays of type boolean are accessed and modified using the byte array instructions baload and bastore.2
The Java virtual machine encodes boolean array components using 1 to represent true and 0 to represent false. Where Java programming language boolean values are mapped by compilers to values of Java virtual machine type int, the compilers must use the same encoding. "
Kaj -
How to store numbers in a stack....
hello guys...i ve got the following assignment:
Write a Java program that reads and evaluates a fully parenthesised arithmetic expression. The
purpose of this program is to illustrate a fundamental use of stacks. Implement the stack using
Linked Lists as explained in your notes.
For e.g if a user enters the expression: (((6 + 9) / 3) * (6 � 4))
The result should be 10.
Your program should be properly documented and well structured. Specifications should be
clearly written in your logbook for all the methods, constructors, and classes that you implement
in the following format:
Class / Method/ Constructor name explaining what it does
Parameters
Preconditions
Postconditions
Throws
Now, i ve come up with the following code:
import java.util.EmptyStackException;
class StackNode {
private static Object data;
private StackNode link;
private static StackNode head;
private int totalnodes;
// the constructors
public StackNode(Object obj, StackNode lk)
data = obj;
link = lk;
public StackNode()
head = null;
totalnodes = 0;
// the push method
public void push(Object obj)
head = new StackNode(obj, head);
totalnodes++;
// the pop method
public Object pop()
Object answer;
if(head == null)
throw new EmptyStackException();
answer = head.getData();
head = head.getLink();
totalnodes--;
return answer;
// the isEmpty method
public boolean isEmpty()
return (head == null);
// get data
public Object getData()
return data;
// get link
public StackNode getLink()
return link;
// size or length method
public int size()
return totalnodes;
public static void main (String args [])
int i;
StackNode number = new StackNode();
StackNode operator = new StackNode();
head = new StackNode(data, head);
number.push(new Integer(9));
number.push(new Integer(6));
operator.push(new Character('+'));
and i dont know how to store numbers into the stack and how to use the operations such as addition substraction division and multiply...
any ideas how to do that??
cheers....This doesn't use a stack but the concept is the same:
import java.util.*;
public class formula {
public int aValue = 1;
public int bValue = 2;
public int cValue = 3;
public formula() {
//StringTokenizer st = new StringTokenizer("a + b/c", " abc()+-*/", true);
//while (st.hasMoreTokens()) { System.out.println(st.nextToken()); }
StringTokenizer st2 = new StringTokenizer("a + (c - b) + (b * c)", " abc()+-*/", true);
int operand1 = 0;
int operand2 = 0;
int operator = 0;
//flag: first operand has a value
boolean firstOperandFull = false;
//flag: second operand has a value
boolean secondOperandFull = false;
//flag: tokens are between parens
boolean inParens = false;
Vector inParensVector = null;
MAINLOOP:
while (st2.hasMoreTokens()) {
String x = st2.nextToken();
//if token is a blank skip it.
if (x.equals(" ")) { continue MAINLOOP; }
System.out.println(x);
//if token is open parens set flag and skip to next token
if (x.equals("(")) { inParens = true; inParensVector = new Vector(); continue MAINLOOP; }
//if tokn is close parens, retrieve the value from between the parens and reset flag.
if (x.equals(")")) { if (! firstOperandFull) { operand1 = doInParens(inParensVector); firstOperandFull = true; }
else { operand2 = doInParens(inParensVector); secondOperandFull = true; }
inParensVector = null; inParens = false; }
//if token is open parens store all tokens until close else process the token
if (inParens) { inParensVector.add(x); }
else {
//if token is a variable put correct value in operand
if (x.equals("a")) { if (! firstOperandFull) { operand1 = aValue; firstOperandFull = true; }
else { operand2 = aValue; secondOperandFull = true; } }
if (x.equals("b")) { if (! firstOperandFull) { operand1 = bValue; firstOperandFull = true; }
else { operand2 = bValue; secondOperandFull = true; } }
if (x.equals("c")) { if (! firstOperandFull) { operand1 = cValue; firstOperandFull = true; }
else { operand2 = cValue; secondOperandFull = true; } }
//if token is a operator store the operation
if (x.equals("+")) { if (firstOperandFull) { operator = 1; } }
if (x.equals("-")) { if (firstOperandFull) { operator = 2; } }
if (x.equals("*")) { if (firstOperandFull) { operator = 3; } }
if (x.equals("/")) { if (firstOperandFull) { operator = 4; } }
System.out.println("operand1 = " + operand1 + " operand2 = " + operand2 + " operator = " + operator);
//if second operand has a value perform the operation.
if (secondOperandFull) {
switch (operator) {
case 1 : operand1 = add(operand1, operand2); secondOperandFull = false; break;
case 2 : operand1 = subtract(operand1, operand2); secondOperandFull = false; break;
case 3 : operand1 = multiply(operand1, operand2); secondOperandFull = false; break;
case 4 : operand1 = divide(operand1, operand2); secondOperandFull = false; break;
}//end switch
} //end if
} //End inParens else
} //End while
System.out.println("answer = " + operand1);
public static void main(String[] args) { //formula f = new formula();
Vector v = new Vector();
StringTokenizer st = new StringTokenizer(",Greg,,Paul,,", ",", true);
String token = null;
String lastToken = " ";
boolean firstToken = true;
while (st.hasMoreTokens()) {
token = st.nextToken();
if (firstToken) { if (token.equals(",")) { v.add("X"); }
firstToken = false; }
if (! token.equals(",")) { v.add(token); }
else { if (lastToken.equals(",")) { v.add("X"); } }
lastToken = token;
} //End While
if (token.equals(",")) { v.add("X"); }
Enumeration tokens = v.elements();
while (tokens.hasMoreElements()) {
System.out.println((String)tokens.nextElement()); }
} //End Main
public int add(int operand1, int operand2) { return operand1 + operand2; }
public int subtract(int operand1, int operand2) { return operand1 - operand2; }
public int divide(int operand1, int operand2) { return operand1 / operand2; }
public int multiply(int operand1, int operand2) { return operand1 * operand2; }
public int doInParens(Vector inParensVector) {
int operand1 = 0;
int operand2 = 0;
int operator = 0;
boolean firstOperandFull = false;
boolean secondOperandFull = false;
Enumeration tokens = inParensVector.elements();
INPARENSLOOP:
while (tokens.hasMoreElements()) {
String x = (String)tokens.nextElement();
//if token is a blank skip it.
if (x.equals(" ")) { continue INPARENSLOOP; }
System.out.println("inparens : " + x);
//if token is a variable put correct value in operand
if (x.equals("a")) { if (! firstOperandFull) { operand1 = aValue; firstOperandFull = true; }
else { operand2 = aValue; secondOperandFull = true; } }
if (x.equals("b")) { if (! firstOperandFull) { operand1 = bValue; firstOperandFull = true; }
else { operand2 = bValue; secondOperandFull = true; } }
if (x.equals("c")) { if (! firstOperandFull) { operand1 = cValue; firstOperandFull = true; }
else { operand2 = cValue; secondOperandFull = true; } }
//if token is a operator store the operation
if (x.equals("+")) { if (firstOperandFull) { operator = 1; } }
if (x.equals("-")) { if (firstOperandFull) { operator = 2; } }
if (x.equals("*")) { if (firstOperandFull) { operator = 3; } }
if (x.equals("/")) { if (firstOperandFull) { operator = 4; } }
System.out.println("Inparens : operand1 = " + operand1 + " operand2 = " + operand2 + " operator = " + operator);
if (secondOperandFull) {
switch (operator) {
case 1 : operand1 = add(operand1, operand2); secondOperandFull = false; break;
case 2 : operand1 = subtract(operand1, operand2); secondOperandFull = false; break;
case 3 : operand1 = multiply(operand1, operand2); secondOperandFull = false; break;
case 4 : operand1 = divide(operand1, operand2); secondOperandFull = false; break;
}//end switch
} //end if
} //End while
System.out.println("Inparens return = " + operand1);
return operand1;
}//End doInParens
}//End Class -
Problems with the Proxy Programme--Please help
Hi All,
I have written a simple proxy server in the form of a servlet. I changed the proxy config of my browser to connect to this servlet hosted on the default context(http://localhost:8080) of the Tomcat 5.0.25 . Well , this servlet internally connects to the proxy of the corporate LAN . The logic that I have applied is as follows. The servlet gets the request from the client (ie the browser in this case) , extracts the headers and contents from the request, sets them to a new request that it forms and finally send this new request to the proxy. When the proxy responds, the servlet collects the response headers and contents adn writes them in its response. To sum up , this servlet transparently carries the requests and responses between the client(browser) and the corporate LAN proxy. Now the problem is this. Let's say , now I am accessing http://www.google.com.The browser sends a request to my servlet with the following headers as they are extracted by my servlet.
ProxyServer:::>posting request
ProxyServer:::>headerValue::> headerName = accept : headerValue=*/*
ProxyServer:::>headerValue::> headerName = referer : headerValue=http://www.google.com/
ProxyServer:::>headerValue::> headerName = accept-language : headerValue=en-us
ProxyServer:::>headerValue::> headerName = proxy-connection : headerValue=Keep-Alive
ProxyServer:::>headerValue::> headerName = user-agent : headerValue=Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; UB1.4_IE6.0_SP1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)
ProxyServer:::>headerValue::> headerName = host : headerValue=www.google.com
ProxyServer:::>headerValue::> headerName = cookie : headerValue=PREF=ID=1be27c0a74f198ca:TM=1082058853:LM=1082058853:S=bu6ORrygzm8AUkm8
ProxyServer:::>postRequest
I set these headers into a new connection opened to the proxy and post a fresh request to the proxy,which, in turn responds with the following headers.
ProxyServer:::>posted request successfully
ProxyServer:::>writing response
ProxyServer:::>writeResponse-->headerName = Proxy-Connection : headerValue = [close]
ProxyServer:::>writeResponse-->headerName = Content-Length : headerValue = [257]
ProxyServer:::>writeResponse-->headerName = Date : headerValue = [Tue, 13 Jul 2004 14:01:40 GMT]
ProxyServer:::>writeResponse-->headerName = Content-Type : headerValue = [text/html]
ProxyServer:::>writeResponse-->headerName = Server : headerValue = [NetCache appliance (NetApp/5.5R2)]
ProxyServer:::>writeResponse-->headerName = Proxy-Authenticate : headerValue = [Basic realm="Charlotte - napxyclt2"]
ProxyServer:::>writeResponse-->headerName = null : headerValue = [HTTP/1.1 407 Proxy Authentication Required]
ProxyServer:::>writeResponse exiting
ProxyServer:::>wrote response successfully
I write these headers back to the client. According to what I was thinking, the client ie the browser would open a new dialog box asking for username/password owing to the presence of the "Proxy-Authenticate " header. But it does not happen that way. Rather the browser stops responsding and displays a blank page. Does anyone know why it happens this way? I am pasting the server prog below for everybody's reference.
package server.proxy;
//import all servlet related classes
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.*;
import java.net.*;
import server.resources.*;
//My Proxy server --->Currently it is very simplea and relies on
//other proxy servers of an already connected network.
public class ProxyServer extends HttpServlet
//stores the resource bundle
private ServerResBundle resBundle = null;
//checks for the mode of operation
private boolean proxySet = false;
private String proxy = null;
//storing the original System out/err etc
private PrintStream sysOutOrig = null;
private PrintStream sysErrOrig = null;
private InputStream sysInOrig = null;
//initialise certain features that are required later
public void init() throws ServletException
try
//initialise the resource bundle
this.initResBundle();
System.out.println("ProxyServer:::>res bundle init");
//set the mode of operation
this.setMode();
System.out.println("ProxyServer:::>mode set");
//set the system out and err --System.setOut etc
this.setSystemOutErr();
System.out.println("ProxyServer:::>in/out/err set");
}//End try
catch(Exception e)
System.out.println("Exception in init..."+(e.getMessage()));
throw new ServletException(e);
}//Edn
catch(Throwable e)
System.out.println("Irrecoverable Error...");
throw new ServletException(e);
}//End
}//End init
//method to init the resource bundle;
private void initResBundle()
this.resBundle = ServerResBundle.getBundle();
}//End
//method to set the mode of the server--proxy or direct
private void setMode()
//read the target proxy property from the bundle and
//if it is set,take that URL
String temp = (String)(this.resBundle.getResource(ResKeys.PROXY_SERVER));
if ( (temp != null) && (temp.length() > 0) )
this.proxySet = true;
this.proxy = temp;
temp = null;
}//End
}//End
//method to set the system out and err etc
private void setSystemOutErr() throws Exception
//keep a copy of the original system out and error
this.sysOutOrig = System.out;
this.sysErrOrig = System.err;
try
//read the options adn if they are set, take the values directly
String newOutStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_OUT));
String newErrStr = (String)(this.resBundle.getResource(ResKeys.SYSTEM_ERR));
if ((newOutStr != null) && (newOutStr.length() > 0))
System.setOut(new PrintStream(new FileOutputStream(new File(newOutStr),true),true));
}//End if
if ((newErrStr != null) && (newErrStr.length() > 0))
System.setErr(new PrintStream(new FileOutputStream(new File(newErrStr),true),true));
}//End if
}//End
catch(Exception e)
//restore the stuff
System.setOut(this.sysOutOrig);
System.setErr(this.sysErrOrig);
}//End
}//End
//this is where the proxy functionalities will be embedded
public void service(HttpServletRequest req,HttpServletResponse resp)
throws ServletException,java.io.IOException
//conenction URL
URL target = null;
//conenction to the remote object
URLConnection targetConn = null;
//stores the OOS and the OIS
ObjectOutputStream oos = null;
ObjectInputStream ois = null;
try
//check for the mode of operation
if (proxySet)
URLConnection objects go through two phases: first they are created, then they are connected.
After being created, and before being connected, various options can be specified
(e.g., doInput and UseCaches). After connecting, it is an error to try to set them.
Operations that depend on being connected, like getContentLength, will implicitly perform the connection,
if necessary.
//for the URL to the proxy
target=new URL(this.proxy);
//conenct to the proxy
targetConn = target.openConnection();
//set the details of the connectuon
targetConn.setDoInput(true);
targetConn.setDoOutput(true);
targetConn.setUseCaches(false);
// If true, this URL is being examined in a context in which it makes sense to allow user interactions such as popping up an authentication dialog. If false, then no user interaction is allowed
targetConn.setAllowUserInteraction(true);
//connect to the remote object
// targetConn.connect();//call this only when all the request properties are set
System.out.println("ProxyServer:::>posting request");
//post the received request to the URL
this.postRequest(targetConn,req);
System.out.println("ProxyServer:::>posted request successfully");
System.out.println("ProxyServer:::>writing response");
//receive the response
//write the received response to the client
this.writeResponse(targetConn,resp);
System.out.println("ProxyServer:::>wrote response successfully");
}//End if
else
//currently this functionality is not supported
throw new ServletException(
(String)(this.resBundle.getResource(ResKeys.ERR_FUNC_NOTSUPPORTED)));
}//End
}//End try
catch(Exception e)
if(e instanceof ServletException)
throw (ServletException)e;
}//End
if (e instanceof IOException)
throw (IOException)e;
}//End
//wrap it up in ServletException
throw new ServletException(e);
}//End
}//End
//method to write the response back to the client
private void writeResponse(URLConnection targetConn,HttpServletResponse resp)
throws ServletException
//get all the header fields from the response connection and set them to the
//response of the servlet
Map headerFields = null;
Iterator headerFieldEntries = null;
Map.Entry header = null;
//stores the input stream to the conn
BufferedReader brConn = null;
//stores the writer to the response
PrintWriter prResp = null;
//checks if the proxy authentication needed or not
boolean proxyAuthReqd = false;
try
//juste ensuring that the proxy authentication is reset
proxyAuthReqd = false;
if( (targetConn != null) && (resp != null) )
//Returns an unmodifiable Map of the header fields.
//The Map keys are Strings that represent the response-header field names.
//Each Map value is an unmodifiable List of Strings that represents the corresponding
//field values
headerFields = targetConn.getHeaderFields();
//Returns a set view of the mappings contained in this map
Set temp = headerFields.entrySet();
//Returns an iterator over the elements in this set
headerFieldEntries = temp.iterator();
if (headerFieldEntries != null)
while (headerFieldEntries.hasNext())
Object tempHeader = headerFieldEntries.next();
if (tempHeader instanceof Map.Entry)
header = (Map.Entry)tempHeader;
Object headerName = header.getKey();
Object headerValue=header.getValue();
System.out.println("ProxyServer:::>writeResponse-->headerName = "+headerName+" : headerValue = "+headerValue);
//do not select the key-value pair if both the key adn the value are null
if ( ( headerName == null) && (headerValue == null) )
continue;
}//Enmd
if (headerValue != null)
List headerValList = null;
if (headerValue instanceof List)
headerValList = (List)headerValue;
}//End
if(headerValList != null)
for (int i=0;i<headerValList.size();i++)
Object headerValueStr = headerValList.get(i);
if (headerValueStr instanceof String)
//note that the header-key can not be null for addHeader
//I have made this temporary provision to make the programme work.
resp.addHeader(( (headerName==null)? ("null_header"+i) :(String)headerName),
(String)headerValueStr);
//check if the proxy authentication required or not
if (((String)headerValueStr).
indexOf(resp.SC_PROXY_AUTHENTICATION_REQUIRED+"") != -1)
System.out.println("ProxyServer:::>writeResponse-->proxy auth needed");
//proxy authentication is needed
proxyAuthReqd = true;
}//End
}//Ednd of
else if (headerValueStr == null)
resp.addHeader(( (headerName==null)? null :(String)headerName),
null);
}//End
}//End for
}//End if
}//End if
}//End
}//End while
}//End if
//get the writer to the client
prResp = resp.getWriter();
System.out.println("ProxyServer:::>writeResponse-->proxyAuthReqd="+proxyAuthReqd);
//juste test a simple header
System.out.println("Proxy-Authenticate = "+(resp.containsHeader("Proxy-Authenticate")));
//if the proxy asks you for authentication,pass on the same to the client
//from whom you have received the request.When this flag is true,the connection
//is closed by the remotehost adn hence any attempt to open in input steram
//results in an error ie IOException
if (!proxyAuthReqd)
//now get the content adn write it to the response too
brConn = new BufferedReader(new InputStreamReader(
targetConn.getInputStream()));
String tempStr = null;
while ((tempStr = brConn.readLine())!=null)
prResp.println(tempStr);
}//End while
//close the connections
brConn.close();
}//End if
else
prResp.println("Proxy Authentication needed...");
}//End
//close the streams
prResp.flush();
prResp.close();
}//End if
System.out.println("ProxyServer:::>writeResponse exiting\n");
}//End try
catch(Exception e)
throw new ServletException(e);
}//End
}//End
//method to post request to the internet
private void postRequest(URLConnection targetConn,HttpServletRequest req)
throws ServletException
//extract the header parameters and the body content from the incoming request
//and set them to the new connection
Enumeration reqHeaders = null;
//reads the incoming request's content
BufferedReader brReqRd = null;
PrintWriter prResWt = null;
//stores temp header names and values
String headerName = null;
String headerValue = null;
try
if( (targetConn != null) && (req != null) )
reqHeaders = req.getHeaderNames();
//extract a header adn set it to the new connection
while (reqHeaders.hasMoreElements())
headerName = (String)(reqHeaders.nextElement());
headerValue = req.getHeader(headerName);
targetConn.setRequestProperty(headerName,headerValue);
System.out.println("ProxyServer:::>headerValue::> headerName = "+headerName+" : headerValue="+headerValue);
}//End
System.out.println("ProxyServer:::>postRequest\n");
//establis the actual connection
//calling this method bfore the above loop results in IllegalStateException
targetConn.connect();
//NOTE : try reading from and writing into OIS and OOS respectively
//now read the contents and write them to the connection
// brReqRd = req.getReader(); //this hangs for some reason
brReqRd = new BufferedReader(new InputStreamReader(req.getInputStream()));
System.out.println("Got the reader..brReqRd = "+brReqRd);
if (brReqRd != null)
String temp = null;
//establish the printwriter
// prResWt = new PrintWriter(targetConn.getOutputStream(),true);
prResWt = new PrintWriter(targetConn.getOutputStream());
System.out.println("trying to read in a loop from brReqRd.. ready="+(brReqRd.ready()));
while( (brReqRd.ready()) && ((temp=brReqRd.readLine()) != null) )
System.out.println("In while::>temp = "+temp);
prResWt.println(temp);
}//Emd while
//close the streams adn go back
brReqRd.close();
prResWt.flush();
prResWt.close();
}//End
}//End outer if
System.out.println("ProxyServer:::>postRequest exiting\n");
}//End try
catch(Exception e)
throw new ServletException(e);
}//End
}//End
}//EndHi serlank ,
Thanks for your reply. Well , I initially I thought of not pasting the code,as it was too long. But I could not help it,as I thought I must show in code what I exactly meant. That's why I followed a description of my problem with the code. You could probably have copied the code and pasted it in one of your favourite editors to take a look at it. Did you,by any chance, try to read it on the browser? And as regards reposting the same message, I can say that I did it as I felt the subject was not quite appropriate in the first posting and I was not sure as to how I could delete/alter the posting. I am not asking for a code-fix,but some suggestions from some one who might ever have come across such a thing.Anyway, lemme know if you have any idea on it. Thanks... -
JDBC control not work after upgrade application from workshop 8.1 to 9.2.3
Hi,
We upgraded application from workshop 8.1 to 9.2.3. After that, the JDBC control not work any more. We got the following exception:
java.sql.SQLException: The transaction is no longer active - status: 'Committed'. No further JDBC access is allowed within this transaction.
at weblogic.jdbc.wrapper.JTSConnection.checkIfRolledBack(JTSConnection.java:192)
at weblogic.jdbc.wrapper.JTSConnection.checkConnection(JTSConnection.java:202)
at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:87)
at weblogic.jdbc.wrapper.Connection.getMetaData(Connection.java:435)
at org.apache.beehive.controls.system.jdbc.parser.SqlStatement.createPreparedStatement(SqlStatement.java:128)
at org.apache.beehive.controls.system.jdbc.JdbcControlImpl.execPreparedStatement(JdbcControlImpl.java:272)
at com.bea.wlw.runtime.core.control.internal.JdbcControlImpl.invoke(JdbcControlImpl.java:136)
at controls.SecurityBean.getUpdateDocPermission(SecurityBean.java:598)
at security.SecurityManagerImpl.getUpdateDocPermission(SecurityManagerImpl.java:110)
at security.SecurityManagerBean.getUpdateDocPermission(SecurityManagerBean.java:509)
The control that throw the exception has "transactionattribute" annotation added automatically by upgrade wizard during upgrading. Related classed are as follows:
@ControlInterface()
public interface SecurityManager
@TransactionAttribute(TransactionAttributeType.REQUIRED)
boolean getUpdateDocPermission(java.lang.String userId);
@ControlImplementation()
public class SecurityManagerImpl implements SecurityManager, Serializable
* @common:control
@org.apache.beehive.controls.api.bean.Control()
private controls.Security security;
static final long serialVersionUID = 1L;
* @common:operation
public boolean getUpdateDocPermission(String userId)
if ( security.getUpdateDocPermission(userId) > 0) {
return true;
else
return false;
@ControlExtension()
@JdbcControl.ConnectionDataSource(jndiName = "EventDesk")
public interface Security extends JdbcControl
static final long serialVersionUID = 1L;
* @jc:sql statement="select r.updateDoc from document_user u ,document_role r where u.login={userId} and u.roleId=r.roleId;"
@JdbcControl.SQL(statement = "select r.updateDoc from document_user u ,document_role r where u.login={userId} and u.roleId=r.roleId;")
int getUpdateDocPermission(String userId);
Thanks for your helpHi. The issue is a level or two above JDBC. I suggest
opening an official support case. It's probably a
WLW issue.
Joe -
BPEL variable access problem - ORABPEL-02118
Hi,
I have a method which accesses the variable of a BPEL process. It worked well with the Soa Suite 10.1.3.1, but I re-install the SOA Suite with the Advanced installation and applied the 10.1.3.3 patch and now I have this error message:
0 - ORABPEL-02118
Variant not found.
The variant "PatientRecordVariable" has not been declared in the current scope. All variants must be declared in the scope before being accessed.
Please check that the variant "PatientRecordVariable" is properly declared; otherwise there may be a misspelling in the name of the variant.
<2007-07-26 11:56:27,829> <ERROR> <default.collaxa.cube> <BaseCubeSessionBean::logError> Error while invoking bean "instance manager": [com.collaxa.cube.engine.EngineException: Variant not found.
The variant "PatientRecordVariable" has not been declared in the current scope. All variants must be declared in the scope before being accessed.
Please check that the variant "PatientRecordVariable" is properly declared; otherwise there may be a misspelling in the name of the variant.
ORABPEL-02118
Variant not found.
The variant "PatientRecordVariable" has not been declared in the current scope. All variants must be declared in the scope before being accessed.
Please check that the variant "PatientRecordVariable" is properly declared; otherwise there may be a misspelling in the name of the variant.
at com.collaxa.cube.engine.core.Scope.getVariantRV(Scope.java:522)
at com.collaxa.cube.engine.CubeEngine.getFieldValue(CubeEngine.java:2956)
at com.collaxa.cube.ejb.impl.InstanceManagerBean.getFieldValue(InstanceManagerBean.java:288)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:31)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at com.evermind.server.ThreadState.runAs(ThreadState.java:648)
at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:34)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)
at InstanceManagerBean_RemoteProxy_4bin6i8.getFieldValue(Unknown Source)
at com.oracle.bpel.client.InstanceHandle.getField(InstanceHandle.java:229)
at webUI.GetTaskData.doGet(GetTaskData.java:50)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
My code does the following calls:
Locator locator = new Locator("default", "bpel");
WhereCondition where = new WhereCondition(SQLDefs.CI_cikey + " = ?");
where.setString(1, taskId);
IInstanceHandle[] instances = locator.listInstances( where );
IInstanceHandle instanceHandle = instances[0];
System.out.println(instanceHandle.getTitle());
HashMap inst = (HashMap)instanceHandle.getField("PatientRecordVariable");
XMLElement dataXML = (XMLElement)inst.get("payload");
String data = XMLHelper.printXML(dataXML);
The problem is at the "getField" method. I was wondering if somebody encountered this error and know how to solve it. I think it should also be possible to access the variable directly from the database (I'm using XE) but I don't know in which table to look.
Any help would be greatly appreciated. Thanks.
AmirWhen I display the debugTrace message for the process instance using
System.out.println(instanceHandle.getDebugTrace());
it gives me this:
<variant key="_$$process-start-time" type="long">1185481662531</variant>
<variant key="_$$++is-sync-operation" type="boolean">false</variant>
<variant key="++properties" id="1" ns1:type="ns2:HashMap">
</variant>
<variant key="_$$audit-trail-count" type="int">1</variant>
<variant key="_$$audit-detail-count" type="int">0</variant>
<variant key="_$$main-scope" id="2" xmlns:ns3="http://www.w3.org/2001/XMLSchema" ns1:type="ns3:string">BpPrc0.1</variant>
<variant key="_$$operation-name" id="3" xmlns:ns4="http://www.w3.org/2001/XMLSchema" ns1:type="ns4:string">initiate</variant>
<variant key="_$$variable-name" id="4" xmlns:ns5="http://www.w3.org/2001/XMLSchema" ns1:type="ns5:string">PatientRecordVariable</variant>
<variant key="_$$++wi-global-table" id="5" xmlns:ns6="com.collaxa.cube.engine.core" ns1:type="ns6:WorkItemLookupTable2">
<work-item ns1:type="ns2:WorkItem">
<key ns1:type="ns2:WorkItemKey">
<instance-id>70017</instance-id><node-id>BpRcv0</node-id><scope-id>BpSeq0.3</scope-id><count-id>1</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
<key ns1:type="ns2:WorkItemKey">
<instance-id>70017</instance-id><node-id>BpAss1</node-id><scope-id>BpSeq0.3</scope-id><count-id>5</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
<key ns1:type="ns2:WorkItemKey">
<instance-id>70017</instance-id><node-id>BpInv0</node-id><scope-id>BpSeq0.3</scope-id><count-id>4</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
<key ns1:type="ns2:WorkItemKey">
<instance-id>70017</instance-id><node-id>BpInv1</node-id><scope-id>BpSeq0.3</scope-id><count-id>6</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
<key ns1:type="ns2:WorkItemKey">
<instance-id>70017</instance-id><node-id>BpAss0</node-id><scope-id>BpSeq0.3</scope-id><count-id>2</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
<key ns1:type="ns2:WorkItemKey">
<instance-id>70017</instance-id><node-id>BxExe1</node-id><scope-id>BpSeq0.3</scope-id><count-id>3</count-id></key><state>closed.finalized</state></work-item></variant>
<variant key="_$$audit-event-count" type="int">16</variant>
</scope><object-store></object-store></scope-context></cube-instance><work-items></work-items></debug-trace>
There is a variant element with the attribute key whose value is "_$$variable-name" and the element has the value "PatientRecordVariable". I don't know if this is related to my problem, but if it is, I still don't understant why it could not get the data of this variable.
Is there any way to get bpel processes' variable data from the database? I browsed the tables but I haven't found them. Hope somebody knows it.
Amir -
How will the typed character in a textField not be printed
Hi all, I want to trap the typed characterfrom the user in a txtField. If
the character is not digit it will not be printed in the componet. I used
keytyped event with the folloing code...
char typedChar = e.getKeyChar();
String currText =txtFldMsBdIndxWeight.getText();
if (!Character.isDigit(typedChar))
if (currText.length()!=0)
currText = currText.substring(0, currText.length()-1);
txtFldMsBdIndxWeight.setText(currText);
else txtFldMsBdIndxWeight.setText("");
the problem is when the text of the componet is empty (currText.length()==0)
the non digit character will be printed in the componet, the code...
txtFldMsBdIndxWeight.setText("");is not working.
What am i doing wrong thank you for advance,
KostasHere is the JNumberField implementation for you
Ashish
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.text.*;
* <P>This Class is used to create number Text Field
public class JNumberField extends JTextField {
private boolean isReal=false;
private int digitCount;
private boolean copyPasteSupported=true;
* <P>This is a default constructor.It creates text field with length of 10 , right aligned and
* without decimal point
* @param
* @return
public JNumberField()
this(10,RIGHT,false);
* <P>This constructor creates text field with specified length , right aligned and
* without decimal point
* @param integer digitCount indicates the length of the text field
* @return
public JNumberField(int digitCount)
this(digitCount,RIGHT,false);
* <P>This constructor creates text field with specified length,specified aligned and
* without decimal point
* @param int digitCount indicates the length of the text field
* int alignment indicates the alignment.It can be LEFT or RIGHT
* @return
public JNumberField(int digitCount,int alignment)
this(digitCount,alignment,false);
* <P>This constructor creates text field with specified length,specified aligned and
* flag to assign decimal point
* @param int digitCount indicates the length of the text field
* int alignment indicates the alignment.It can be LEFT orRIGHT
* boolean isReal flag to set decimal point
* @return
public JNumberField(int digitCount,int alignment,boolean isReal)
this(digitCount,alignment,isReal,false);
* <P>This constructor creates text field with specified length,specified aligned and
* flags to assign decimal point and to support copy paste operation
* @param int digitCount indicates the length of the text field
* int alignment indicates the alignment.It can be LEFT or RIGHT
* boolean isReal flag to set decimal point
* boolean copyPasteSupported flag to support copy paste
* @return
public JNumberField(int digitCount,int alignment,boolean isReal,boolean copyPasteSupported)
setDocument(new NumberDocument());
setDigitCount(digitCount);
setHorizontalAlignment(alignment);
setReal(isReal);
setCopyPasteSupported(copyPasteSupported);
addKeyListener(new JNumberFieldKeyAdapter());
* <P>This method sets the flag to support copy paste operation
* @param boolean copyPasteSupported flag to support copy paste
* @return
public void setCopyPasteSupported(boolean copyPasteSupported)
this.copyPasteSupported=copyPasteSupported;
* <P>This method checks the copy paste is supported
* @param
* @ return boolean copyPasteSupported flag
public boolean isCopyPasteSupported()
return copyPasteSupported;
* <P>This method sets the Real Value support flag
* @ param boolean isReal flag to set the Real value
* @ return
public void setReal(boolean isReal)
this.isReal=isReal;
* <P>This method checks whether Real Value is accepted
* @param
* @ return boolean isReal flag
public boolean isReal()
return isReal;
* <P>This method sets the text alignment
* @param int alignment value can be LEFT or RIGHT
* @return
public void setHorizontalAlignment(int alignment)
if(alignment==LEFT || alignment==RIGHT)
super.setHorizontalAlignment(alignment);
* <P>This method gets the no of digits of text field
* @param
* @return int digitCount
public int getDigitCount()
return digitCount;
* <P>This method sets the no of digits of text field
* @param int digitCount of text field
* @return
public void setDigitCount(int digitCount)
this.digitCount=digitCount;
* <P>This is an inner Class which overrides the Document Class
public class NumberDocument extends PlainDocument {
* <P>This method overrides insertString method of PlainDocument Class
* @param int offset - The Location of a String to be inserted
* String String str - The String to be inserted
* AttributeSet a - Attributes of a text Field
* @return
* @Exception throws BadLocationException when the offset value is negative or exceeds the
* length of the text field
public void insertString(int offset, String str, AttributeSet a) throws BadLocationException
if((getLength()+1) >getDigitCount())
return;
if(str.length()==1)
if(Character.isDigit(str.charAt(0)))
super.insertString(offset,str,a);
else
if(str.charAt(0)=='.' && isReal())
if(JNumberField.this.getText().indexOf('.')<0)
super.insertString(offset,str,a);
else
boolean isStringContainsChar=false;
for(int i=0;i<str.length();i++)
if(!Character.isDigit(str.charAt(i)))
isStringContainsChar=true;
break;
if(!isStringContainsChar)
super.insertString(offset,str,a);
* <P>This is an inner Class which listens the Key Events
public class JNumberFieldKeyAdapter extends KeyAdapter {
String textBeforKeyPressed="";
* <P>This method captures the Key Event and prevents the copy paste operation
* if copy paste is not supported
* @param KeyEvent ke - captured Key Event
* @return
public void keyPressed(KeyEvent ke)
char keyChar=ke.getKeyChar();
if(keyChar=='\r' || keyChar=='\n')
System.out.println("EnterPressed ");
String modifire=ke.getKeyModifiersText(ke.getModifiers());
if((modifire.equalsIgnoreCase("Ctrl") || keyChar=='v' || keyChar=='V')&& !isCopyPasteSupported())
ke.consume(); -
Doubt in calculating a ratio in a query
Good afternoon forum,
I have a question on how to calculate a ratio in a query.
I have 2 ratios: Actual Cost and Cost Periodificado. And from these two I have to calculate other ratios (WIP).
So the logic would be the following:
A) If the actual cost is greater than the cost periodificado, the difference in these two ratios correspond to the ratio WIP (WORK IN PROGRESS).
B) If the actual cost is <periodificado the cost, the difference in these two ratios correspond to the ratio WIP (PROVISION OF SPENDING)
To reveal a ratio or the other depending on which of two conditions is met.
If the condition is fulfilled, will be displayed in the query ratio WORK IN PROGRESS, and if the condition B is displayed on the query ratio
PROVISION OF SPENDING.
I do not know if I have explained well. Any suggestions?
Thank you.The logic presented by Rakesh seems to be appropriate .
u need to follow and utilise the Boolean operators...
go to query designer
lets say the ratio u need to display is in columns
now right clik and say new formulae
from there select the Formulae operator as Boolean operators
use follwong formulae
WORK IN PROGRESS = (actual cost > cost periodificado) * (actual cost - cost periodificado)
PROVISION IN SPENDING = (actual cost < cost periodificado) * ( cost periodificado - actual cost)
Hit okey
go to actual costs properties
put the display option as HIDE
repeat the same for Cost periodificado
go to query properties
use the option SUPRESS ZERO VALUES FOR rows and columns....
this way u will only display the required result -
Please help with web services (JSR 172)
Hello!
I'm in need of some help. I've only worked with web services some few weeks. I have two web services that I want to access from J2ME.
Both works nice in regular Java (J2SE). I use axis so with the help of WSDL2Java I got a working client.
One of them has four operations
public boolean tryToLoginUser( String username, String password ) {}
public boolean tryToLogOffUser( String username, String password ){}
public boolean createUserAccount( String username, String password ){ }
public boolean removeUserAccount( String username, String password ){ } The problem is when I want to use Sun's Wireless Toolkit 2.2 and create stubs that way with the Stub Generator. It complains with this
warning: Operation tryToLoginUser is of the wrong encoding SOAP style/use (rpc/encoded). Document/literal only. Skipping generation of operation.
warning: Operation tryToLogOffUser is of the wrong encoding SOAP style/use (rpc/encoded). Document/literal only. Skipping generation of operation.
warning: Operation createUserAccount is of the wrong encoding SOAP style/use (rpc/encoded). Document/literal only. Skipping generation of operation.
warning: Operation removeUserAccount is of the wrong encoding SOAP style/use (rpc/encoded). Document/literal only. Skipping generation of operation.What I can tell is I need to put this in my axis deployment descriptor
<service name="UserWebService" provider="java:RPC" style="document" use="literal">instead of this:
<service name="UserWebService" provider="java:RPC">This wont work. It don't work with HTTP GET I get this error
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.</faultstring>
- <detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">slukare</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>I doesn�t work with WSDL2Java and when I run Sun's Wireless Toolkit 2.2 to generate stub it complains with
warning: ignoring operation "tryToLoginUser": more than one part in input message
warning: ignoring operation "tryToLogOffUser": more than one part in input message
warning: ignoring operation "createUserAccount": more than one part in input message
warning: ignoring operation "removeUserAccount": more than one part in input message
warning: Port "UserWebService" does not contain any usable operationsDoes this mean I can only use one parameter for input in an operation when I use style="document" use="literal" ??
I understood it that way, so I created a new web service that takes username and password in one String.
The new web service has four operations
public boolean tryToLoginUser( String usernameAndPassword ) {}
public boolean tryToLogOffUser( String usernameAndPassword ){}
public boolean createUserAccount( String usernameAndPassword ){ }
public boolean removeUserAccount( String usernameAndPassword ){ }The problem is that I get this error when running HTTP GET.
<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.userException</faultcode>
<faultstring>org.xml.sax.SAXException: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize.</faultstring>
- <detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">slukare</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>If I get a WSDL2Java client it works (!) if I manually changes the parameter names. I have four operations which all takes
String usernameAndPassword
in one String since I can only use one parameter with style="document" use="literal"
The WSDL2Java automatically set the parameter names to
usernameAndPassword
usernameAndPassword1
usernameAndPassword2
usernameAndPassword3
for the different operations. If I manually changes them to all have the name
usernameAndPassword
it works. Why doesn�t it work without manual changes? I haven�t tested the code from Sun�s Wireless Toolkit 2.2 Stub Generator yet, but that at least doesn�t give any errors .
My other web service doesn�t work either if I set style="document" use="literal".
This web service returns my own classes I have written. It works as I said previously in J2SE with WSDL2Java, but not with style="document" use="literal�. When I set this my byte[] which is returned is null when using the client from WSDL2Java, this wasn�t the case without style="document" use="literal�.
I also get an error in Sun�s Wireless Toolkit 2.2 that byte[] is not recoigniced. This wasn�t the case with axis WSDL2Java.
If I put this inside the axis deployment descriptor
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service xmlns:j2melab2="urn:businessobject.j2melab2"
name="RecipeWebService" provider="java:RPC" style="document" use="literal">
<parameter name="scope" value="session"/>
<parameter name="className" value="j2melab2.webservices.RecipeWebService"/>
<parameter name="allowedMethods" value="*"/>
<typeMapping qname="j2melab2:ArrayOfString"
type="java:java.lang.String[]"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding"/>
<beanMapping qname="j2melab2:Recipe" languageSpecificType="java:j2melab2.businessobject.Recipe"/>
<beanMapping qname="j2melab2:Ingredient" languageSpecificType="java:j2melab2.businessobject.Ingredient"/>
<typeMapping qname="j2melab2:ArrayofIngredient"
type="java:j2melab2.businessobject.Ingredient[]"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding"/>
<typeMapping qname="j2melab2:ArrayOfByte"
type="byte[]"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding"/>
</service>
</deployment>instead of this
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service xmlns:j2melab2="urn:businessobject.j2melab2"
name="RecipeWebService" provider="java:RPC">
<parameter name="scope" value="session"/>
<parameter name="className" value="j2melab2.webservices.RecipeWebService"/>
<parameter name="allowedMethods" value="*"/>
<typeMapping qname="j2melab2:ArrayOfString"
type="java:java.lang.String[]"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding"/>
<beanMapping qname="j2melab2:Recipe" languageSpecificType="java:j2melab2.businessobject.Recipe"/>
<beanMapping qname="j2melab2:Ingredient" languageSpecificType="java:j2melab2.businessobject.Ingredient"/>
<typeMapping qname="j2melab2:ArrayofIngredient"
type="java:j2melab2.businessobject.Ingredient[]"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding"/>
</service>
</deployment>axis WSDL2Java won�t work anymore. And Sun�s Wireless Toolkit doesn�t work either with this. How can I get this to work with Sun�s Wireless Toolkit 2.2?
So my questions are:
Do I really need style=�document� use=�literal� for J2ME?
Can I only have one parameter as input when I use style=�document� use=�literal� ?
Why do I need to manally change the parameter names?
How can I make Sun�s Wireless Toolkit 2.2 understand byte[] ?
Many thanks for help :) (I have to present a solution in 1 � week to my J2ME teacher L).hi,
i was wandering if you manage to successfully generate the stubs through the wireless toolkit at the end? i am currently having similar problem (i.e., trying to generate stub files based on wsdl from axis)? it seems that the WTK can only handle document/literal format, and so i change the wsdl to that. however, now it complains that it can't handle more than one input part in the message, (which is similar to the problem you had). so did you manage to find a solution to that, or J2ME simply does not support more than one arguement as the input?
thanks in advance,
lee
Maybe you are looking for
-
Can't get plug-in for Acrobat to work in Safari (boy I've tried!)
I've spent literally hours in the discussion group looking for an answer to this and can't find one that works, so I finally decided to post a new topic. I just moved from a Powerbook G4 to a MBP. On the G4, when I brought up a PDF file from a web pa
-
How do I best share all photos on one iMac with two user accounts?
I recently bought an iMac and Aperture. I am converting from a windows-based platform. My immediate pain point is the ability to share one library in Aperture under both my account and my wife's user account(like we do our iTunes, for example). We wo
-
Hi Gurus, FG has a price of moving average. It was the client's decision. Now from the new financial year they want to maintain standard price for FG. How to proceed & what will be its implications. Regards, Kumar
-
After rebuild a index need do more something?
If i move the indexes of "TESTE" schema to other tablespace and that indexes have been access for user "TESTEC" i will need to grant and recriate sinonym again for the that user? O will use: select 'alter index "'||owner||'"."'||index_name||'" re
-
Laptop monitor stays black with Windows but not with Ibuntu
Can someone tell me why my daughter's Compaq laptop has no video, monitor is black, in Windows Vista but works fine with Ibuntu? The service shop said it is a bad video card but wouldn't that apply to the computer and not work in either operating sy