OnvifClientPTZ onvif c++ unable to get configuration options - c++

tt__Profile *t = profiles.Profiles.at(0);
OnvifClientPTZ PTZ(onvifDevice);
_tptz__GetConfigurationOptions tptz__GetConfigurationOptions;
_tptz__GetConfigurationOptionsResponse tptz__GetConfigurationOptionsResponse;
tt__PTZConfigurationOptions *options;
int response = PTZ.GetConfigurationOptions(tptz__GetConfigurationOptionsResponse, t->token);
Problem is that PTZ#GetConfigurationOptions returns value of 1 (#response).
Object #onvifDevice seems to be fine (onvifDevice.hasPTZ returns true).
I've tried debugging and onvifDevice.GetPTZUrl(strUrl) returns true and sets strUrl to 192.168.1.88:2000/device/services which is soap_endpoint of PtzProxy object (ptzProxy.soap_endpoint = strUrl.c_str();) and it seems to be fine. Also soap_action is "www.onvif.org/ver20/ptz/wsdl/GetConfigurationOptions" which also seems to be fine.
I'm using https://github.com/xsmart/onvifcpplib.
In PTZ proxy returns here:
tptz__GetConfigurationOptionsResponse->soap_get(soap, "tptz:GetConfigurationOptionsResponse", "");
if (soap->error)
return soap_recv_fault(soap, 0);
Any help would be appreciated.

I've found the solution. Problem was in this line:
int response = PTZ.GetConfigurationOptions(tptz__GetConfigurationOptionsResponse, t->token);
OnvifPTZClient#GetConfigurationOptions requests PTZConfiguration token, not profile token. So correct line would be:
response = PTZ.GetConfigurationOptions(tptz__GetConfigurationOptionsResponse, tr->PTZConfiguration->token);

Related

Calling a Web Service (containg multiple pages) does not load all the pages (without an added sleep delay)

My question is about a strange behavious I notice both on my iPhone device and the codenameone simulator (NetBeans).
I invoke the following code below which calls a google web service to provide a list of food places around a GPS coordinate:
The web service that is called is as follows (KEY OBSCURED):
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXXXXXXXXXXXXXXXXX
Each result contains the next page token and thus, the second call (for the subsequent page) is as follows:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXXXXXXXXXXXXXXXXX&pagetoken=YYYYYYYYYYYYYYYYYY
public static byte[] getWSResponseData(String urlString, boolean usePost)
{
ConnectionRequest r = new ConnectionRequest();
r.setUrl(urlString);
r.setPost(usePost);
InfiniteProgress prog = new InfiniteProgress();
Dialog dlg = prog.showInifiniteBlocking();
r.setDisposeOnCompletion(dlg);
NetworkManager.getInstance().addToQueueAndWait(r);
try
{
Thread.sleep(2000);
}
catch (InterruptedException ex)
{
}
byte[] responseData = r.getResponseData();
return responseData;
}
public static void getLocationsList(double lat, double lng)
{
boolean done = false;
while (!done)
{
byte[] responseData = getWSResponseData(finalURL,false);
result = Result.fromContent(parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(responseData))));
String venueNames[] = result.getAsStringArray("/results/name");
nextToken = result.getAsString("/next_page_token");
if ( nextToken == null || nextToken.equals(""))
done = true;
else
finalURL = completeURL + "&pagetoken=" + nextToken;
}
.....
}
This code works fine with the sleep timer, but when I remove the Thread.sleep, only the first page gets called.
Any help would be appreciated.
Using the debugger does not help as this is a timing issue and the issue does not occur when using the debugger.
Also when I put some print statements into the code
while (!done)
{
String nextToken = null;
**System.out.println(finalURL);**
...
}
System.out.println("Total Number of entries returned: " + itemCount);
I get the following output:
First Run (WITHOUT SLEEP):
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXX
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXX&pagetoken=CqQCF...
Total Number of entries returned: 20
Using the network monitor I see that the response to the second WS call returns:
{
"html_attributions" : [],
"results" : [],
"status" : "INVALID_REQUEST"
}
Which is strange as when I cut and paste the WS URL into my browser, it works fine...
Second Run (WITH SLEEP):
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXXX
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXXX&pagetoken=CqQCFQEAA...
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=40.714353,-74.00597299999998&radius=200&types=food&key=XXXXXXXXX&pagetoken=CsQDtQEAA...
Total Number of entries returned: 60
Well it seems to be a google API issue as indicated here:
Paging on Google Places API returns status INVALID_REQUEST
I still could not get it to work by changing the WS URL with a random parameter as they suggested, but I will keep trying and post something here if I get it to work. For now I will just keep a 2 second delay between the calls which seems to work.
Well gave up on using the google WS for this and switched to Yelp, works very well:
https://api.yelp.com/v3/businesses/search?.....

TransferClient returns no error message after failed operation

I have been trying to use TransferClient in C++ from the official SDK following the tests in the SDK. But when I run the following code, I don't get a human readable string. Ideas?
TransferClientConfiguration transferConfig;
transferConfig.m_uploadBufferCount = 20;
static const char* ALLOCATION_TAG = "TransferTests";
ClientConfiguration config;
std::shared_ptr<S3Client> m_s3Client = Aws::MakeShared<S3Client>(ALLOCATION_TAG, config, false);
std::shared_ptr<TransferClient> m_transferClient = Aws::MakeShared<TransferClient>(ALLOCATION_TAG, m_s3Client, transferConfig);
std::string s3path = "akey";
std::shared_ptr<UploadFileRequest> requestPtr = m_transferClient->UploadFile(filepath.string(), "testbucket", s3path.c_str(), "", false, true);
requestPtr->WaitUntilDone();
if (!requestPtr->CompletedSuccessfully())
{
// requestPtr->GetFailure() returns a blank string here??
}
Figured out the problem! Turns out the bucket is in us-west-1 and for what ever reason, the transfer client with the default client option doesn't work.

Changing WS API from Play Framework! 2.4 to 2.5

With Playframework! 2.5 the result of a WS request is now a CompletionStage<WSResponse>.
CompletionStage <WSResponse> completionStage = ws.url("http://url/enewsletter/signupAuto.aspx")
.setRequestTimeout(2500)
.setQueryParameter("email", user.getEmail())
.get();
CompletionStage <String> resultPromise = completionStage.thenApply(WSResponse::getBody);
//String result = responsePromise.get(2500).getBody();
String result = ""; // ?????
I could easy get the result from the promise in before using the F.Promise<WSReponse> but I don't see to get how to get the result with CompletionStage. I need the result for processing before continuing the procedure.
The reason I like to have the result is that this function is performed in a 'for' loop gathering information which then is returned.
I think I found it in:
completionStage.toCompletableFuture();

SOAP Fault when Using DocuSign API with Salesforce for Creating Envelope with Templates

I am using Salesforce with DocuSign to try and create an envelope via templates.
DocuSignAPI.EnvelopeTemplates templates = soapService.requestTemplates(accountId, false);
String templateId = templates.EnvelopeTemplateDefinition[0].TemplateID;
DocuSignAPI.EnvelopeTemplate template = soapService.requestTemplate(templateId, false);
DocuSignAPI.EnvelopeInformation envelopeInformation = new DocuSignAPI.EnvelopeInformation();
envelopeInformation.Subject = 'XXXXXXXXXXX';
envelopeInformation.AccountId = accountId;
envelopeInformation.EmailBlurb = 'XXXXXXXXXXXXX';
DocuSignAPI.TemplateReference templateReference = new DocuSignAPI.TemplateReference();
templateReference.RoleAssignments = new DocuSignAPI.ArrayOfTemplateReferenceRoleAssignment();
templateReference.Template = template.EnvelopeTemplateDefinition.TemplateID;
templateReference.TemplateLocation = 'Server';
DocuSignAPI.Recipient recipient = new DocuSignAPI.Recipient();
recipient.ID = currentRecipientIndex + 1;
recipient.Type_x = 'Signer';
recipient.Email = 'XXXXXXXXXXXXXXXX';
recipient.UserName = 'XXXXXXXXXXXXXXXXX';
recipient.RoutingOrder = 1;
DocuSignAPI.ArrayOfRecipient1 recipients = new DocuSignAPI.ArrayOfRecipient1();
recipients.Recipient = new DocuSignAPI.Recipient[1];
recipients.Recipient.add(recipient);
DocuSignAPI.TemplateReferenceRoleAssignment trra = new DocuSignAPI.TemplateReferenceRoleAssignment();
trra.RoleName='Stake holder';
trra.RecipientID = recipient.ID;
templateReference.RoleAssignments.RoleAssignment = new DocuSignAPI.TemplateReferenceRoleAssignment[1];
templateReference.RoleAssignments.RoleAssignment.add(trra);
DocuSignAPI.ArrayOfTemplateReference arrayOfTemplateReference = new DocuSignAPI.ArrayOfTemplateReference();
arrayOfTemplateReference.TemplateReference = new DocuSignAPI.TemplateReference[1];
arrayOfTemplateReference.TemplateReference.add(templateReference);
DocuSignAPI.EnvelopeStatus status = soapService.createEnvelopeFromTemplates(arrayOfTemplateReference, recipients, envelopeInformation, true);
However, upon running the code, I get the following error:
Web service callout failed: WebService returned a SOAP Fault: Unspecified_Error faultcode=soap:Server faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx
And this references the DocuSignAPI where the WebServiceCallout is invoked. Given the ambiguity of the error, I would appreciate any thoughts on what could be causing this.
As an update to this post, I was able to find the error. The indexing for Apex starts at 0 not 1 (unlike MatLab which is what caused my confusion). Because I was starting at index 1, the XML request was passing 'null' values at the 0th index, causing the error. Starting at 0, removed the null values from the XML and the request went through.

gsoap c++ android device encoding

8.15,
I can connect my microsoft web service and I can insert record with this service easily.
I get a confirmation code as a response for record insert. But I have a problem with encoding. The response message must like this 1Exa9GwOIO6pP35l4TJ1Bw== but instead of this I get a response like this 4�� u #
When I try this service on a browser I get the expected response as
in 1Exa9GwOIO6pP35l4TJ1Bw==
But when I try it on an android device with gsoap I get a response such as this one 4�� u #
How can I solve this encoding problem?
TheGameSoapProxy service;
_ns1__PlayerRegisterResponse* response = new _ns1__PlayerRegisterResponse();
std::string telNO =m_pEditTel->getText();
std::string telefonIME = "111";
std::string simCardID = "222";
std::string Username = m_pEditName->getText();
std::string takim = Takim.c_str();
_ns1__PlayerRegister* ps = new _ns1__PlayerRegister();
ps->telefonNumarasi = &telNO;
ps->telefonIME = &telefonIME;
ps->simCardID = &simCardID;
ps->Username = &Username;
ps->takim = &takim;
if (service.PlayerRegister(ps, response) == SOAP_OK)
{
string *ptrSonuc = response->PlayerRegisterResult;
CCLog( (char*)ptrSonuc );
}
As per other question here on SO:
add the line below to your typemap.dat file:
xsd__string = | wchar_t* | wchar_t*
And then use wstrings instead of strings.