cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping to Digital Signature (web service scenarios)

Former Member
0 Kudos

Hi All,

I'm working with Web Service Scenarios and I have a problem.

The Web Service has a Schema for validation data and I send data to method of WS, example:

Web Service Description

<SendData xmlns="http://www.sdn.com/schema.xsd">

<InputXML>string</InputXML>

</SendData>

For send data to "InputXML" is obligatory digital signature in Java.

I created a Java Mapping where get message of schema xsd, clear prefixes of tag and convert all schema to string.

Now Web Service response a error, because string is not contain "<" ">" just contain asc & lt; & gt;

Ex:

& lt;CodigoMunicipio& gt;2927408& lt;/CodigoMunicipio& gt;

In Debug Java Mapping in statement:

before

<CodigoMunicipio>2927408</CodigoMunicipio>;

rootelement.appendChild(element);

After

& lt;CodigoMunicipio& gt;2927408& lt;/CodigoMunicipio& gt;

And If use a rotine to convert it, in sxi_monitor generate a exception because not understand string field.

Can you help me?

Regards,

Bruno

Accepted Solutions (0)

Answers (2)

Answers (2)

henrique_pinto
Active Contributor
0 Kudos

But "& lt;" is string.

Do you need or need not to pass as string?

If you're talking about NFe 2,00 version, note that it doesn't expect the content in string format anymore, but rather in XML format.

Best regards,

Henrique.

former_member182503
Active Contributor
0 Kudos

Eagle eyes! I didn't noticed the "space" between "&" and the "gt;"

[]'s

JN

henrique_pinto
Active Contributor
0 Kudos

But I think that space was added manually by him, in order to be able to write it in the forums.

Otherwise, the forum unescapes "& lt;" (without space) into "&lt;".

BR,

Henrique.

Former Member
0 Kudos

Hi JN / Henrique,

It's NFSe Project (BR).

The webservice expects to receive a String

<a href=https://nfsehml.sefaz.salvador.ba.gov.br/envioloterps/envioloterps.svc>https://nfsehml.sefaz.salvador.ba.gov.br/envioloterps/envioloterps.svc</a>

I'm trying test with 2 forms, after I post the result.

For some others cities It's work.

The spaces is manually for post.

Other problem is the field Id, because Salvador use "id" and not "Id" in Schema and when sent to signature response:

Unexpected exception signing input XML

Invalid referenceId (not found on the input XML)

Any Ideia?

Thank you for helpful...

Regards,

Bruno

p.s: I using Ws NFE to signature and is this case "id"/"Id", i think i need to create a new core of signature(and already start)

Edited by: BrunoLima on Dec 10, 2010 10:59 PM

former_member182503
Active Contributor
0 Kudos

Bruno,

Now I got it.

The JWS component from SLL-NFE expects the "Id" attribute. If you send the tag to be signed with the attribute "id" instead of "Id" it will give this error to you.

I guess that, if the Salvador WS doesn't accept the "Id" as attribute, you will need to develop a custom EJB to do the Digital Signature, just changing the name of the attribute that will be signed.

I guess that the "Id" parameter is hardcoded (I'm not sure) in tc_sec_ssf.jar, that is the core of JWS component.

Best regards,

JN

0 Kudos

Hi Bruno,

I'm facing the same problem with Salvador, but I have no idea how to generate a new core to signature.

Were you able to solve this problem? Could you give me any clue?

Tks in advance.

Flavio Ribeiro.

former_member182503
Active Contributor
0 Kudos

Hi Bruno,

there are two ways to nest a xml document into another xml document.

The first one is escaping the XML, just like you did:

<document_one>
<input_xml>
&gt;document_two&lt;&gt;tag_a&lt;value&gt/tag_a&lt;&gt;/document_two&lt;
</input_xml>
</document_one>

http://stackoverflow.com/questions/1091945/where-can-i-get-a-list-of-the-xml-document-escape-charact...

The other is using the CDATA tag.

<document_one>

<input_xml>

<![CDATA[<document_two><tag_a>value</tag_a></document_two>]]>

</input_xml>

</document_one>

http://www.w3schools.com/xml/xml_cdata.asp

Then, if your webservice expects to receive a XML document inside the InputXML tag, probably it will be able to handle one of these techniques.

Best regards,

JN