Integration of APEX and JasperServer - oracle-apex

I'm trying to launch jasperreports (on jaspersoft server) via APEX dynamic actions.
When I am executing this i receive a error:
Even when I'm only trying to login
DECLARE
v_blob BLOB;
v_file_name VARCHAR2 (25) := 'TestReport.pdf';
v_vcContentDisposition VARCHAR2 (25) := 'inline';
v_invoice_id VARCHAR2(10) := :INVOICE_ID; -- your NumberField Item
v_hostname VARCHAR2(30) := #HOST#; -- your hostname, eg: localhost
v_port NUMBER := #PORT#; -- port for your JasperReports Server, eg: 8081
v_username VARCHAR2(50) := 'jasperadmin'; -- jasperreports server username
v_password VARCHAR2(50) := 'jasperadmin'; -- jaspereports server password
v_jasper_string VARCHAR2(30) := v_username || ';' || v_password;
v_login_url VARCHAR2(100) :=
'http://' || v_hostname || ':' || v_port || '/jasperserver/rest/login';
v_report_url VARCHAR2(100) :=
'http://' || v_hostname || ':' || v_port || '/jasperserver/rest_v2/reports/Reports/' || v_file_name;
BEGIN
-- log into jasper server
v_blob := apex_web_service.make_rest_request_b(
p_url => v_login_url,
p_http_method => 'GET',
p_parm_name => apex_util.string_to_table('j_username;j_password',';'),
p_parm_value => apex_util.string_to_table(v_jasper_string,';')
); APEX_APPLICATION.STOP_APEX_ENGINE;
EXCEPTION
WHEN OTHERS THEN
RAISE;
END;
The APEX and JasperServer are on different ports.

Have you added the target ip:port to the ACL?
https://docs.oracle.com/database/121/ARPLS/d_networkacl_adm.htm#ARPLS148

Problem was with the https protocol. Apex had https and Jasperserver didn't.
The conclusion is that both (apex and jasperserver) need to have https.
Edit:
In addittional I needed to create proper ACL and create Oracle Wallet to avoid "Certificate Validation Error"

Related

Golang Paho MQTT over Websocket

Hey I was trying to connect to AWS IoT Core via Golang Paho MQTT client. I tried the normal MQTT connection which was working without problems. Next I wanted to try the connection via MQTT over Websocket but could not find anything relating that in the Paho.Mqtt docs. How do I make the Websocket connection? I could post my code from my normal MQTT connection if necessary.
Edit, here is my code:
package main
import (
"crypto/tls"
"fmt"
"time"
MQTT "github.com/eclipse/paho.mqtt.golang"
)
type Message struct {
message string
}
/*var f MQTT.MessageHandler = func(client MQTT.Client, msg MQTT.Message) {
fmt.Printf("TOPIC: %s\n", msg.Topic())
fmt.Printf("MSG: %s\n", msg.Payload())
}*/
func main() {
cer, err := tls.LoadX509KeyPair("cd5a04e9fd9a094326c9ee0cdc1e1f7b2e3510a9e106968683d333a2a4344ca7-certificate.pem.crt",
"./cd5a04e9fd9a094326c9ee0cdc1e1f7b2e3510a9e106968683d333a2a4344ca7-private.pem.key")
check(err)
cid := "ClientID"
// AutoReconnect option is true by default
// CleanSession option is true by default
// KeepAlive option is 30 seconds by default
connOpts := MQTT.NewClientOptions() // This line is different, we use the constructor function instead of creating the instance ourselves.
connOpts.SetClientID(cid)
connOpts.SetMaxReconnectInterval(1 * time.Second)
connOpts.SetTLSConfig(&tls.Config{Certificates: []tls.Certificate{cer}})
host := "a2to6mbspmaw82-ats.iot.eu-west-1.amazonaws.com"
port := 443
brokerURL := fmt.Sprintf("wss://%s:%d", host, port)
connOpts.AddBroker(brokerURL)
mqttClient := MQTT.NewClient(connOpts)
if token := mqttClient.Connect(); token.Wait() && token.Error() != nil {
panic(token.Error())
}
var message = "message from lap"
for message != "bye" {
token := mqttClient.Publish("some_topic", 0, false, message)
token.Wait()
message = "bye"
}
}
func check(err error) {
if err != nil {
panic(err)
}
}
From the Eclipse Paho GoLang page
The type of connection required is specified by the scheme of the
connection URL set in the ClientOptions struct, for example:
tcp://mqtt.eclipseprojects.io:1883 - connect to mqtt.eclipseprojects.io on port 1883 using plain TCP
ws://mqtt.eclipseprojects.io:1883 - connect to mqtt.eclipseprojects.io on port 1883 using WebSockets
tls://mqtt.eclipseprojects.io:8883 - connect to mqtt.eclipseprojects.io on port 8883 using TLS (ssl:// and tcps:// are
synonyms for tls://)
The second entry in the list suggests you just pas in the URL with the right schema ( ws:// or probably wss://)

AWS Go SDK not finding the credentials file at C:/###/.aws/credentials

I am using Amazon Kinesis and the Go SDK for AWS, but I'm getting an error.
This is my code:
package main
import (
"math/rand"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
_kinesis "github.com/aws/aws-sdk-go/service/kinesis"
)
func main() {
session, err := session.NewSession(&aws.Config{
Region: aws.String("us-east-1"),
})
handleErr(err)
kinesis := _kinesis.New(session)
laugh := strings.Builder{}
laughingSounds := []string{"haha", "hoho", "hehe", "hehehe", "*snicker*"}
for i := 0; i < 10; i++ {
laugh.WriteString(laughingSounds[rand.Intn(len(laughingSounds))])
}
_, err = kinesis.PutRecord(&_kinesis.PutRecordInput{
Data: []byte(laugh.String()),
PartitionKey: aws.String("laughs"),
StreamName: aws.String("laughs"),
})
handleErr(err)
}
func handleErr(err error) {
if err != nil {
panic(err)
}
}
When I run this, I get an error:
panic: UnrecognizedClientException: The security token included in the request is invalid.
status code: 400, request id: dc139793-cd38-fb30-86a3-f92b6410e1c7
goroutine 1 [running]:
main.handleErr(...)
C:/Users/####/----/main.go:5
main.main()
C:/Users/####/----/main.go:34 +0x3ac
exit status 2
I have run aws configure:
$ aws configure
AWS Access Key ID [None]: ####
AWS Secret Access Key [None]: ####
Default region name [None]: us-east-1
Default output format [None]:
and the C:/users/####/.aws/credentials file is created with the correct configuration. But my program still wouldn't execute successfully.
I tried to set an environment variable, but to no avail.
$ $env:aws_access_key_id="####"
Version info:
$ pwsh -v
PowerShell 7.2.2
$ aws -v
aws-cli/2.4.27 Python/3.8.8 Windows/10 exe/AMD64 prompt/off
OS: Windows 11
I found the answer in GoDoc, I just had to change a config setting and use NewSessionWithOptions:
session, err := session.NewSessionWithOptions(session.Options{
Config: aws.Config{
Region: aws.String("<your region>"),
}, SharedConfigState: session.SharedConfigEnable,
})
Be sure to run aws configure with the correct credentials (or even just manually create the ~/.aws/credentials file), or this won't work.

get status code from a gRPC endpoint not using a gRPC client

How could I get the status code from a gRPC endpoint without having a gRPC client?
I need to test some gRPC endpoints that are behind an AWS application load balancer (target group) with a health check configured to only accept status 12
UNIMPLEMENTED 12 The operation is not implemented or is not supported/enabled in this service.
I tried grpcurl for example:
grpcurl -plaintext 10.1.2.8:8443 AWS.ALB/healthcheck:
But in many cases I get:
Error invoking method "AWS.ALB/healthcheck": failed to query for service descriptor "AWS.ALB": server does not support the reflection API
Any alternatives or ideas? I am just interested in the status code 12 or description UNIMPLEMENTED
For status code 12, you can change it through
alb.ingress.kubernetes.io/success-codes: '0' // change success code to 0
spec:
rules:
- host: server.xxx.com
http:
paths:
- path: /* // set to * to match all grpc service paths
backend:
serviceName: server
servicePort: 9420
Also enable server reflection
## -40,6 +40,7 ## import (
"google.golang.org/grpc"
pb "google.golang.org/grpc/examples/helloworld/helloworld"
+ "google.golang.org/grpc/reflection"
)
const (
## -61,6 +62,8 ## func main() {
}
s := grpc.NewServer()
pb.RegisterGreeterService(s, &pb.GreeterService{SayHello: sayHello})
+ // Register reflection service on gRPC server.
+ reflection.Register(s)
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}

How to install and Certificates HTTPRIO connection

I import the WSDL file. GetCA from the WSDL file that were imported rust is in the function.
The following example of a block of code when I run the program.
Where the function is called whoami in receipt of the certificate has not been installed error. How to install and Certificates HTTPRIO connection?
begin
HTTPRIO1.WSDLLocation := defWSDL;
HTTPRIO1.Service := defSvc ;
HTTPRIO1.Port := defPrt ;
HTTPRIO1.URL := defURL;
b := WhoAmIMessage.Create;
a := ReplyMessage.Create;
Cert := TElX509Certificate.Create(nil);
try
F := TFileStream.Create(CertFile, fmOpenRead or fmShareDenyWrite);
CERT.LoadFromStreamPFX(f, CertPass);
F.Position := 0;
HTTPRIO1.HTTPWebNode.OnBeforePost := OnBeforePost;
Trs := GetCA(True, ' ', HTTPRIO1);
B := Trs.WhoAmI;
ShowMessage(BoolToStr(B.IsAuthenticated));
finally
a.Free;
b.Free;
Cert.Free;
FreeAndNil(F);
end;
end;

Accessing web service in oracle 10g pl/sql procedures

I’m using soap_api method for accessing web services in oracle. When I create add_numbers function and I execute add_numbers function then Function doesn’t execute.
fires following error when calling web service in select statement
select add_numbers(2,5) from dual
error is
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP",line 1029
ORA-12541: TNS:no listener
ORA-06512: at "dbtest.SOAP_API",line 144
ORA-06512: at "dbtest.ADD_NUMBERS", line 34 FROM!
I’m using this function and soap_api methods from this link. taken example from
http://www.oracle-base.com/articles/9i/consuming-web-services-9i.php#Top
Function for calling web services.
CREATE OR REPLACE FUNCTION add_numbers (p_int_1 IN NUMBER, p_int_2 IN NUMBER) RETURN NUMBER AS
l_request soap_api.t_request;
l_response soap_api.t_response;
l_return VARCHAR2(32767);
l_url VARCHAR2(32767);
l_namespace VARCHAR2(32767);
l_method VARCHAR2(32767);
l_soap_action VARCHAR2(32767);
l_result_name VARCHAR2(32767);
BEGIN
l_url := 'http://192.168.0.75:9001/LicWebService.asmx';
l_namespace := 'xmlns="http://192.168.0.75:9001/"';
l_method := 'AddNum';
l_soap_action := 'http://192.168.0.75:9001/AddNum';
l_result_name := 'return';
l_request := soap_api.new_request(p_method => l_method, p_namespace=> l_namespace);
soap_api.add_parameter(p_request => l_request,p_name => 'int1',p_type => 'xsd:integer',p_value => p_int_1);
soap_api.add_parameter(p_request => l_request,p_name=> 'int2', p_type=> 'xsd:integer',p_value => p_int_2);
l_response := soap_api.invoke(p_request => l_request, p_url=> l_url, p_action => l_soap_action);
l_return := soap_api.get_return_value(p_response => l_response,p_name=> l_result_name, p_namespace => NULL);
END;
Kindly suggest me where i am making mistake.
Either your TNS is not set up properly or the TNS service is not running. This is the reason why the UTL_HTTP api isn't working (which is used by SOAP_API).
Follow this link to troubleshoot and resolve this.