Where does your code set the schema for responses as "hsm-resp-" ?
It looks like 'command' is a key field - forming part of the name of
lower level schema?
You need to make the leap over to hsm-resp- for the response handling?
Perhaps receiving an FSDMsg (with a base schema of
"file:src\\iris\\hsm-resp-") instead of an ISOMsg with a DummyPackager
(from Channel) will help?
--
Mark
Can you change the names of the response schema to remove the -resp part?
That way, the requests and responses are part of the same schema, split
by the command value?
Are hsm-base.xml and hsm-resp-base.xml essentially the same?
> When I remove the last line
> with channel.receive() method I don't get any response.
Yes, because then you are not receiving anything back.
> Could be casting ISOMsg to FSDISOMsg brings the error?
I doubt it?
Andy will be up in a few hours, I'm sure he will know how best to do
this - I have not done it you see.
--
Mark
1. hsm-base.xml, 2.hsm-NC.xml, 3. hsm-ND.xml
?
I guess the problem is making sure the unpack knows which schema to use...
... we need an expert on Channel/(ISO)FSDMsg receiving...
... I don't have time to work it out 8(.
--
Mark
May I suggest that it is time to try and describe your current environment?
This should include changes you have made to the jPos source. Remember
that we cannot see those and they may well be breaking the flow. Also
include the components (Channels, MUX etc).
If you can describe each part of your solution and the jPos components
(Schema/Packager, Channel (with headers) etc), we may be able to 'feel'
what might be busted.
If you have not changed too much, perhaps a diff of your changes here
might help us see what you are doing wrong?
We should remember that jPos as it stands works for others, so something
is 'now' incorrect in your setup.
Can you also indicate if you have control of the 'hsm simulator'? If
you do are you matching the channels, the packagers/schema and the
header handling at both ends?
--
Mark
What error are you getting - we need to know.
Looking through the code...
>...I have even reimplemented the code as told by Andy but
> all in vain.
> I have even reinvented my code to look like this:
> The Adaptor code is :
>
> private FSDMsg createRequest (String command) {
> FSDMsg req = new FSDMsg ("file:src/iris/hsm-");
> if (command != null)
> req.set ("command", command);
> return req;
> }
>
> public FSDMsg diagnostics () throws MalformedURLException,
> JDOMException, IOException, ISOException {
> return command (createRequest ("NC"));
> }
>
> public FSDMsg command (FSDMsg request) throws
> MalformedURLException, JDOMException, IOException, ISOException {
> FSDMsg resp = null;
> String s = request.pack();
> if(s!=null){
So at this point you have a byte[] containing your request (which is not
null), but you do nothing with it in the way of sending it across a network?
> resp = new FSDMsg ("file:src/iris/hsm-resp-");
> resp.unpack(s.getBytes());
.. but then you unpack your request byte[] as your response!
> }
> else
> resp.dump(System.out, "");
>
> return resp;
> }
>
>
> and my main class is :
> FSDChannel channel=new FSDChannel();
> ISOPackager pack=new DummyPackager();
> channel.setHost("127.0.0.1", 9998);
> channel.setPackager(pack);
> HSMAdaptor adaptor=new HSMAdaptor();
> FSDMsg msg=adaptor.diagnostics();
The above instruction probably fails with an unpack error because you
are attempting to unpack your request as a response!
> FSDISOMsg isomsg=new FSDISOMsg(msg);
> isomsg.setHeader(new byte[]{1,2,3,4});
> channel.connect();
> channel.send(isomsg);
Now you send the 'request/response' from *outside* of the HSMAdaptor...
> channel.receive();
Then you try and receive something, but don't do anything with it!?
Please note that adaptor.diagnostics() should probably send a diagnostic
request to the HSM and return the response?
>
>
> and I am including infact five not four files i.e hsm-base,hsm-resp-
> base, hsm-NC, hsm-resp-NC, hsm-resp-ND files. Am just working on a
> simple class to check if I can send and receive from my thales HSM
> simulator.
>
> In my FSDChannel I added the following two methods:
>
> protected int getMessageLength() throws IOException, ISOException {
> int len = super.getMessageLength();
> LogEvent evt = new LogEvent (this, "fsd-channel-debug");
> evt.addMessage ("received message length: " + len);
> Logger.log (evt);
> return len;
> }
> protected int getMessageLength(DataInputStream serverIn) throws
> IOException {
> byte[] b = new byte[2];
> serverIn.readFully(b,0,2);
> return (int) (
> ((((int)b[0])&0xFF) << 8) |
> (((int)b[1])&0xFF));
> }
>
> When I send I get the null reponse..
When you send what?
Where are you getting a 'null' 'response'? Remember your
channel.receive line is throwing anything it gets away, I suspect you
are not getting that far.
>
> Do I need to make adjustment also in my basechannel?
You need to understand what it is you are trying to do and how you might
do it.
You seemed totally confused and your code is poorly written - perhaps
just because you are confused and don't understand things. Is java a
language you use often?
>
> I am not give up..
We can tell, but currently you have a mess.
It is a *lot* easier than you are making this - honestly.
Your HSM adaptor - if anything like Andy's will have a socket that it
would use to send a request and receive the response through.
I think it might be worth starting over, untangling what you have would
be a nightmare - especially remotely and via email
Read carefully through Andy's blog, search this mailing list, understand
what you need to do and then set out to do it.
I don't think we can help you in this aspect unless someone does your
work for you...
... perhaps that is an option you need now to consider?
--
Mark
What happens?
>
> channel.receive();
But you are still not trying to do anything with any response that comes
back. The processing of the inbound message will fail because you are
still have no way of letting the Channel know that the bytes arriving
back need to be unpacked using the response schema.
Where did you get the base source for your 'ThalesAdaptor' from; or can
you show us the entire item?
--
Mark