SOAP client SAAJ - java

I am relatively new to SOAP and wanted to write a SOAP client in JAVA. I figured out that the WSDL has a lot of other crap and as I use just one service out of it, hence SAAJ would be the shortest way. The first WSDL I got was RPC encoded and did not support SSL connections (http link). The call I made was this:
String request = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:AxessInterface\">"
+ " <soapenv:Header/>"
+ " <soapenv:Body>"
+ " <urn:getModemFromACS soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">"
+ "<ModemIDMACAddressChoice xsi:type=\"urn:ModemIDMACAddressChoiceStruct\">"
+ " <ModemID xsi:type=\"xsd:string\">"
+ modemId
+ "</ModemID>"
+ " </ModemIDMACAddressChoice>"
+ " </urn:getModemFromACS>"
+ " </soapenv:Body>"
+ "</soapenv:Envelope>";
The new WSDL that I have is I guess NOT RPC encoded (it does not have that "style=rpc" tag anywhere) and the link is SSL enabled (https with one way authentication). The style is "document" in this WSDL.
I have a couple of issues:
My soap call doesnt work. I modified it to be:
String request = "http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:AxessInterface\">"
+ " "
+ " "
+ " "
+ " "
+ " "
+ modemId
+ ""
+ " "
+ " "
+ " "
+ "";
I am not sure why the code cannot be displayed, i removed the line "soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" . With this i get a SOAPFault with message: "list index out of range"
Can someone tell me how to add that truststore to my SOAP client? (I use System.setProperty but I am not sure if this is the best way to go).

Related

How can I solve two errors adding "?useUnicode"?

I am connecting to a MySQL database but I got an error about timezone. So I solved it by adding useLegacyDatetimeCode=false&serverTimezone=UTC:
String url = "jdbc:mysql://" + host + ":" + port + "/" + db_isim +
"?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
Now I need to add this too: ?useUnicode=true&characterEncoding=utf8
Is there a way for this?
(Not very good at English so basic explanation or just the code will be good)
I need to add this code for Turkish characters. I tried adding next to it but the connection went lost.
You can type the code in the following format and if you encounter a problem in the connection make sure the variables used within the code or make sure to add jdbc library
String url = "jdbc:mysql://" + host + ":" + port + "/" + db_isim + "?useUnicode=true&useJDBCCompliantTimezoneShift=true&characterEncoding=utf8&useLegacyDatetimeCode=false&serverTimezone=UTC";
Have you tried :
String url = "jdbc:mysql://" + host + ":" + port + "/" + db_isim
+ "?useUnicode=true&"
+ "useJDBCCompliantTimezoneShift=true&"
+ "useLegacyDatetimeCode=false&"
+ "serverTimezone=UTC&"
+ "characterEncoding=utf8";

Convert Loadrunner File Parameter to Java string for payload

I have a java virtual user script that is sending a payload request. I am trying to use values from a file to send via a loadrunner file parameter.
here is the payload:
private static final String PAYLOAD =
"<ips_cad_mdt>\n" +
" <SignOnRequest>\n" +
" <DestApplication>hhhh</DestApplication>\n" +
" <OrigApplication>hhh</OrigApplication>\n" +
" <SessionRef>3</SessionRef>\n" +
" <Aliasing>1234</Aliasing>\n" +
" </SignOnRequest>\n" +
"</ips_cad_mdt>";
I would like to use something like the following:
private static final String PAYLOAD =
"<ips_cad_mdt>\n" +
" <SignOnRequest>\n" +
" <DestApplication>hhh</DestApplication>\n" +
" <OrigApplication>hhh</OrigApplication>\n" +
" <SessionRef>3</SessionRef>\n" +
" <Aliasing>”+lr.eval_string(“{AliasId}”)+”</Aliasing>\n" +
" </SignOnRequest>\n" +
"</ips_cad_mdt>";
for some reason i cant see any output for this value. do i need to declare a variable: e.g. lr.save_string("AliasId", "{AliasId}");
an example of this would help loads. Many Thanks
There seems to be an error in the code completion in VuGen. The parameters should be reversed and without the {} in save_string.
lr.save_string("1234","myId");
lr.message(lr.eval_string("{myId}"));
In the documentation it is correct - https://admhelp.microfocus.com/lr/en/12.55/help/function_reference/FuncRef.htm#FuncRef/c_vuser/lrFr_lr_save_string.htm?Highlight=lr_save_string
I asked the responsible team to fix the code completion in VuGen so you will be able to see this change in one of the future releases.

How to use GetLineReq in AXL Java Client using JAX-WS

What I'm trying to do is to obtain a Directory Number from CUCM, using the AXL API from Cisco. Here's the relevant Code:
private void getNumber(){
AXLAPIService axlService = new AXLAPIService();
AXLPort axlPort = axlService.getAXLPort();
String validatorUrl = "https://mycucm:8443/axl/";
((BindingProvider) axlPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, validatorUrl);
((BindingProvider) axlPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, Demo.ucAdmin);
((BindingProvider) axlPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, Demo.ucPswd);
GetLineReq axlParams = new GetLineReq();
axlParams.setPattern("7491817");
axlParams.setUuid("{48a6ff28-cea7-fc3e-3d82-8cc245ed4ea3}");
GetLineRes getLineResponse = axlPort.getLine(axlParams);
Demo.informUser("Line Information: \n"
+ "Alerting Name: " + getLineResponse.getReturn().getLine().getAlertingName() + "\n"
+ "Dial Number: " + getLineResponse.getReturn().getLine().getPattern() + "\n"
+ "Description: " + getLineResponse.getReturn().getLine().getDescription() + "\n"
+ " " + getLineResponse.getReturn().getLine().getShareLineAppearanceCssName());
}
As you can tell from this diagram it is only necessary to specify either the uuid or the pattern of the number:
But the code only works, if I specify the uuid, which is not, what I'm trying to achieve. The only thing i have given, is the pattern, which I want to use, to get all the other information. I Already examined this site from Cisco: How to ... Create an AXL Java Client using JAX-WS
When I leave out the uuid I get this Error:
Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Item not valid: The specified Line was not found
I also checked, how the Directory Number is stored inside the CUCM Database using the AXLSqlToolkit:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header/><SOAP-ENV:Body><axl:executeSQLQueryResponse xmlns:axl="http://www.cisco.com/AXL/API/7.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" sequence="1405672933992"><return><row><dnorpattern>7491817</dnorpattern><pkid>48a6ff28-cea7-fc3e-3d82-8cc245ed4ea3</pkid></row></return></axl:executeSQLQueryResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>
Does anyone know, how I can obtain the Directory Number, only by using the pattern-value?
I figured it out myself. The routePartitionName is also a mandatory parameter, which had to be specified. Here's the working code of my method:
private void getNumber(){
AXLAPIService axlService = new AXLAPIService();
AXLPort axlPort = axlService.getAXLPort();
String validatorUrl = "https://mycucm:8443/axl/";
((BindingProvider) axlPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, validatorUrl);
((BindingProvider) axlPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, Demo.ucAdmin);
((BindingProvider) axlPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, Demo.ucPswd);
GetLineReq axlParams = new GetLineReq();
ObjectFactory objectFactory = new ObjectFactory(); //This is new
XFkType routePartition = new XFkType();
routePartition.setValue("PHONES"); // This is where you specify your route partition name
axlParams.setPattern("7491817");
axlParams.setRoutePartitionName(objectFactory.createGetLineReqRoutePartitionName(routePartition));
GetLineRes getLineResponse = axlPort.getLine(axlParams);
Demo.informUser("Line Information: \n"
+ "Alerting Name: " + getLineResponse.getReturn().getLine().getAlertingName() + "\n"
+ "Dial Number: " + getLineResponse.getReturn().getLine().getPattern() + "\n"
+ "Description: " + getLineResponse.getReturn().getLine().getDescription() + "\n"
+ " " + getLineResponse.getReturn().getLine().getShareLineAppearanceCssName());
}

How can I split the data over multiple lines in a JTextArea?

How can I put each line of the host in the message body? I work with a JTextArea.
String host = InetAddress.getLocalHost().getHostName().toString();
texto_recepcion.setText(host + texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido + "\n");
How it is now:
I resolve my question with append function.
String host = InetAddress.getLocalHost().getHostName().toString();
texto_recepcion.append(host); // ***Use the function append for solve the problem***
texto_recepcion.setText(texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido + "\n");
Thanks a lot
Why don't you add the newline character "\n" to the beginning of the string?
texto_recepcion.setText("\n" + host + texto_recepcion.getText() + dpRecepcion.getAddress() + " " + mensaje_recibido);

Meeting request timing mismatch with full VS lite outlook version

I am creating meeting request with java code and sending it to full as well as lite version of outlook as shown below:
final SimpleDateFormat iCalendarDateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmm'00'");
final long uid =System.currentTimeMillis();
iCalendarDateFormat.setTimeZone(TimeZone.getTimeZone(MRBSConstants.TIMEZONE));
final String calendarContent = "BEGIN:VCALENDAR\n"
+ "METHOD:REQUEST\n"
+ "PRODID: BCP - Meeting\n"
+ "VERSION:2.0\n"
+ "BEGIN:VEVENT\n"
+ "DTSTAMP:"+ iCalendarDateFormat.format(meetingEndTime) + "\n"
+ "DTSTART:" + iCalendarDateFormat.format(meetingStartTime) + "\n"
+ "DTEND:"+ iCalendarDateFormat.format(meetingEndTime) + "\n"
+ "SUMMARY:test request\n"
+ "UID:" + uid + "\n"
+ "ATTENDEE;ROLE=REQ-PARTICIPANT;PARTSTAT=NEEDS-ACTION;RSVP=TRUE:MAILTO:" + Arrays.toString(recipetList) + "\n"
+ "ORGANIZER:MAILTO:" + from+ "\n"
+ "LOCATION:" +loc + "\n"
+ "DESCRIPTION:" + body+ "\n"
+ "SEQUENCE:0\n" + "PRIORITY:5\n" + "CLASS:PUBLIC\n" + "STATUS:CONFIRMED\n" + "TRANSP:OPAQUE\n" + "BEGIN:VALARM\n"
+ "ACTION:DISPLAY\n" + "DESCRIPTION:REMINDER\n" + "TRIGGER;RELATED=START:-PT00H15M00S\n" + "END:VALARM\n" + "END:VEVENT\n" + "END:VCALENDAR";
And it is working fine with lite version of outlook means it giving correct time in lite version but in full version of outlook it showing different timings.?why
Here MRBSConstants.TIMEZONE value is GMT-5:30.
I have also tried adding VTIMEZONE COMPONENT but in that case outlook cant recognize the ics file as correct.
Do we have any general ics object which can work on both version?

Categories