I have generated Tokenpassort in java but I do not see how to use it in Java. All samples I have seen are in C#
1) NetSuiteServiceLocator does not take tokenpassport
2) NetSuiteService is an interface.
3) NSPORT takes in passport but NOT tokenpassport.
How to use tokenpassport in Java ( not C# ) ?
SHORT ANSWER: The token goes into a SOAP Header named "tokenPassport" in the SoapEnvelope. One way to make that happen is via the javax.xml.rpc.Stub class's setHeader method.
HERE'S WHAT WORKED FOR ME:
import org.apache.axis.client.Stub;
import org.apache.axis.message.SOAPHeaderElement;
import com.netsuite.webservices.platform.core_2019_1.TokenPassport; // WSDL version 2019.1
import com.netsuite.webservices.platform_2019_1.NetSuitePortType; // WSDL version 2019.1`<br/>
TokenPassport tokenPassport = ...;
NetSuitePortType port = ...;`<br/>
String namespace = "urn:messages_2019_1.platform.webservices.netsuite.com"; // WSDL version 2019.1
SOAPHeaderElement tokenPassportHeader =
new SOAPHeaderElement(nameSpace, "tokenPassport", tokenPassport);
((Stub) port).setHeader(tokenPassportHeader);
NOTE: The *_2019_1 packages are soap client packages generated by Axis using NetSuite's WSDL for version 2019.1.
ONE OTHER PITFALL: The algorithm name that NetSoft expects in TokenPassportSignature.algoritm is NOT the same as the name used in java's SecretKeySpec constructor. For example, the SecretKeySpec uses "HmacSHA256", but TokenPassportSignature expects "HMAC-SHA256".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.