I am trying to make a request (Security Definition Request) to FIX Adapter using the following method. This is an application level call and I manually invoke this method whenever there is a successful connection to FIX Adapter.
WHen i run this method i get a "Field not found for tag:49" exception message. However SecurityDefinitionRequest class doesnt allow me to set Tag 49 (SenderCompId) to it.
First of all is this the right way to make a SecurityDefinitionRequest? I tried looking at QuickFix/N docs but they dont explain how to make such request.
http://quickfixn.org/tutorial/sending-messages.html
Infact i havent seen any articles so far in the internet. Any suggestions?
public void ToApp(Message message, SessionID sessionId)
{
var request =
new SecurityDefinitionRequest()
{
SecurityReqID = new SecurityReqID("1"),
SecurityID = new SecurityID("5"),
SecurityRequestType = new SecurityRequestType(3),
SecurityType = new SecurityType("FUT")
};
request.SetField(new SenderCompID("217"));
Session.SendToTarget(request);
}
The constructed message looks like this
8=FIX.4.29=3735=c48=549=217167=FUT320=1321=310=003
I'm going to suggest:
SessionId currentSessionId = new QuickFix.SessionID("FIX4.2", "217","CBOE");
securityDefinitionRequest.SetSessionID(currentSessionId );
Related
We're trying to use the REST API of Administration Service to manage the Configuration Manager
(What is the administration service in Configuration Manager?)
We have successfully queried entities of different types and executed some custom static methods (i.e. MoveMembers Method on SMS_ObjectContainerItem). It's all mostly blind shots as there is barely any documentation, but those basic functionalities seem to work fine.
Now we have hit the wall, trying to add collection rules to a SMS_Collection (existing or new). This was normally done calling the AddMembershipRule on the instance itself, that was previously fetched by e.g. WqlConnectionManager or some other proxy. However, this is clearly a no-go on a plain object fetched from the REST service.
We have tried to use the wmi OData service (by a generated proxy) as it clearly offers similar functionality, but this ends up with a "Not supported exception":
var savedCollection = Proxy.SMS_Collection.Where(c => c.CollectionID == result.CollectionID).FirstOrDefault();
savedCollection.AddMembershipRule(inclusionRule);
Proxy.UpdateObject(savedCollection);
Proxy.SaveChanges(); //EXCEPTION
I have tried running POST request in numerous ways, using urls like:
SMS_Collection.AddMembershipRule?CollectionID=DV000037 -> 404
SMS_Collection/DV000037/AddMembershipRule -> 404
SMS_Collection.DV000037.AddMembershipRule -> 404
SMS_Collection/DV000037.AddMembershipRule -> treated it as post to SMS_Collection/DV000037, and therefore triggers an update
or just
SMS_Collection.AddMembershipRule with collectionID as param
As for the request body I've used (or just the AddCollectionMembershipRuleRequestRule):
public class AddCollectionMembershipRuleRequest
{
public AddCollectionMembershipRuleRequestRule CollectionRule { get; set; }
}
public class AddCollectionMembershipRuleRequestRule
{
public string RuleName { get; set; }
public string IncludeCollectionID { get; set; }
}
I have also tried to Post an existing or new collection, with CollectionRules prefilled, but this ends up with an exception complaining about IncludeCollectionID not being part of CollectionRule (base class) - looks like validation being too strict and not dealing well with the inheritance.
var collectionRequest = new ECMCollectionCreationRequest()
{
Name = collectionName,
CollectionType = 2,
RefreshType = 4,
LimitToCollectionID = DefaultLimitingCollectionID,
CollectionRules = new List<SMS_CollectionRule>()
{
new SMS_CollectionRuleIncludeCollection()
{
RuleName = "MembershipRule",
IncludeCollectionID = "DV100020"
}
}
};
Stil, no luck with any of those. Do you have any idea if such a scenario (modification of CollectionRules) is even supported with the Rest /OData service? If so, what would be the right way to achieve so?
It looks like this part is simply not supported at the moment. Looking at the code it seems that the service is not interpreting the arguments properly and therefore causing validation issues.
However, the same can be achieved, in a bit less clean and structured way, using ManagementScope and ManagementObject
var scope = new ManagementScope(siteAddress);
scope.Connect();
using (ManagementObject collection = new ManagementObject(scope, new ManagementPath($"SMS_Collection.CollectionID='{collectionID}'"), new ObjectGetOptions()))
{
if (collection == null)
throw new Exception($"Unable to find collection with ID '{collectionID}'");
collection.Get();
using (ManagementBaseObject inParams = collection.GetMethodParameters("AddMembershipRule"))
using (ManagementClass ruleClass = new ManagementClass(scope, new ManagementPath("SMS_CollectionRuleDirect"), new ObjectGetOptions()))
using (ManagementObject rule = ruleClass.CreateInstance())
{
rule["ResourceClassName"] = "SMS_R_System";
rule["ResourceID"] = ecmResourceID;
rule["RuleName"] = machineName;
inParams["collectionRule"] = rule;
collection.InvokeMethod("AddMembershipRule", inParams, null);
}
}
One can add and remove all the other rule types in similar way.
Another alternative is of course to use PowerShell. Sill, I hope that with one of the next iterations of the Administration Service, support of those methods will be added.
Similarly, there seems to be no way to add/remove application or package and import/export them, using the admin services or even in the way mentioned above.
$Rule="{'collectionRule':{`"#odata.type`": `"#AdminService.SMS_CollectionRuleDirect`", `"ResourceClassName`": `"SMS_R_System`", `"ResourceID`": $DeviceID,`"RuleName`": `"$MachineName`"}}"
$RuleCreated = (Invoke-RestMethod -Method Post -Uri "https://$($CMProvider)/AdminService/wmi/SMS_Collection('$CollectionID')/AdminService.AddMembershipRule" -Body $Rule -ContentType 'application/json' -Credential $Cred)
I am trying to develop a control IP camera with ONVIF.But I have a little problem of connect PTZ server of ONVIF.
Here is my code:
private void PTZTest(DeviceClient client, double deviceTimeOffset, string ip, int port)
{
// Create Media object
string xaddr = string.Format("http://{0}/onvif/device_service", txtIP.Text);
MediaClient mediaService = OnvifServices.GetOnvifMediaClient(xaddr, deviceTimeOffset, txtUser.Text, txtPassword.Text);
// Create PTZ object
string xaddr2 = string.Format("http://{0}/onvif/ptz_service",txtIP.Text);
PTZClient ptzService = OnvifServices.GetOnvifPTZClient(xaddr2, deviceTimeOffset, txtUser.Text, txtPassword.Text);
// Get target profile
Profile[] mediaProfiles = mediaService.GetProfiles();
Profile mediaProfile = mediaService.GetProfile(mediaProfiles[0].token);
PTZConfigurationOptions ptzConfigurationOptions = ptzService.GetConfigurationOptions(mediaProfile.PTZConfiguration.token);
PTZ.PTZSpeed velocity = new PTZ.PTZSpeed();
velocity.Zoom = new PTZ.Vector1D() { x = speed * ptzConfigurationOptions.Spaces.ContinuousZoomVelocitySpace[0].XRange.Max };
When I set a breakpoint at the line
PTZConfigurationOptions ptzConfigurationOptions = ptzService.GetConfigurationOptions(mediaProfile.PTZConfiguration.token); I got this error message:
There was no listening endpoint on
http://192.168.123.2/onvif/ptz_service that could accept the message.
This is often due to an incorrect SOAP address or action. If present,
see the InnerException element for more information.
But I dont understand why I can have the list of the PTZ services and all the informations about the mediaService, but I couldn't get the ptzconfiguration option.
Does anyone know what's the problem exactly ? And how can I resolve it, please!
Not every onvif device will host its PTZ service on the same endpoint. Generally the approach to use is to query the GetServices/GetCapabilities calls from the DeviceService. This is the only service that usually always has the same URL - "http://ip/onvif/device_service"
Approach to use is therefore(in pseudocode)
var devService = OnvifServices.GetOnvifDeviceService("http://ip/onvif/device_service)
var services = devService.GetServices() or devService.GetCapabilities()
var ptzServiceInfo = services.Where(x => x.Name.Contains("Ptz));
var ptzServiceInfo = OnvifServices.GetPtzService(ptzServiceInfo.Url);
you do not use the device_server to do any ptz_service calls, you simply use it to do a lookup for the correct URL of the device service If you do the GetService call the response will include something like
<tds:Service> <tds:Namespace>onvif.org/ver20/ptz/wsdl</tds:Namespace> <tds:XAddr>ip/onvif/ptz</tds:XAddr> </tds:Service>
See onvif.org/specs/core/ONVIF-Core-Specification-v250.pdf for more details
So I'm building an app with twilio voice, and I've got all the phonecall stuff working. But I'm having a little trouble understanding which parameters my callback should have.
I've registered the URL as described in the docs:
options.From = formatPhoneNumber(callout.callback_number);
options.To = formatPhoneNumber(offer.employee_phone_number);
options.Url = TwilioCallBotController.TwilioCalloutScriptURL;
options.StatusCallback = TwilioCallBotController.StatusCallbackURL;
options.StatusCallbackEvents = new []{"initiated", "ringing", "answered", "completed" };
options.StatusCallbackMethod = "POST";
I've also made a callback method here, but I'm not having much luck finding out how the parameters are supposed to work with their API. I'm kindof at a loss as to what could be the reason behind this one not working:
[HttpPost]
public ActionResult TwilioStatusCallback()
{
var twiml = new Twilio.TwiML.TwilioResponse();
twiml.Say("This is a test");
string CallSid = Request.Form["CallSid"];
string CallStatus = Request.Form["CallStatus"];
Debug.WriteLine("Status Callback Delivered");
Shift_Offer shoffer = db.Shift_Offers.Where(s => s.twillio_sid == CallSid).ToList()[0];
shoffer.status = CallStatus.ToString();// + DateTime.Now.ToString();
return TwiML(twiml);
}
Edit:
So it turns out that the API is very sensitive about the method signature (the call was previously throwing a method not found exception in a number of microsoft DLLs, including System.Web and System.Web.Mvc.
So I've actually gotten the software to call the method by using an empty method signature (no parameters).
However I'm still having trouble getting the parameters from the HTTPPOST
Edit: So upon further investigation I've managed to inspect the Request. The values I'm after exist in Request.Form["foo"], but they don't seem to be getting put into the two strings I have declared. I've removed the ["HttpPost"] attribute to try to troubleshoot the issue, but I'm really at a loss as to why I can see the values in the debugger, but they're not translating into memory.
public ActionResult TwilioStatusCallback()
{
var twiml = new Twilio.TwiML.TwilioResponse();
string sid = Request.Form["CallSid"];
string status = Request.Form["CallStatus"];
Shift_Offer shoffer = db.Shift_Offers.Where(s => s.twillio_sid == sid).ToList()[0];
shoffer.status = status;// + DateTime.Now.ToString();
return TwiML(twiml);
}
Last issue was that the database wasn't being saved.
Just added a db.SaveChanges() and we're good.
I'm trying to use the VersionOne API via the C# APIClient, but my meta model is only getting an Unknown AssetType error wrapping a 405 exception. What am I doing wrong? Here's a code snippet:
VersionOneAPIConnector conn = VersionOneClientFactory.CreateClient(Endpoint.Data);
conn.WithVersionOneUsernameAndPassword("username", "password");
IMetaModel meta = new MetaModel(VersionOneClientFactory.CreateClient(Endpoint.Meta));
Services s = new Services(meta, conn);
If it helps, here's the CreateClient method:
public static VersionOneAPIConnector CreateClient(Endpoint e)
{
StringBuilder url = new StringBuilder("https://www#.v1host.com/MyCompany/");
switch (e)
{
case Endpoint.Data: url.Append("rest-1.v1"); break;
case Endpoint.Localization: url.Append("loc-2.v1"); break;
case Endpoint.Meta: url.Append("meta.v1"); break;
case Endpoint.Query: url.Append("query.v1"); break;
}
return new VersionOneAPIConnector(
url.ToString(),
proxyProvider: new ProxyProvider(
new Uri("http://proxy.server"),
"proxy_username",
"proxy_password"
));
}
Here's what I see in Visual Studio:
In this case I use a breakpoint to show you the issues in the Locals window. If I were to actually try to do anything, the MetaException gets thrown.
I tried your code and ran into the same issue. I was able to make it work by adding a "/" at the end of each endpoint (the meta endpoint in particular). Could you try that?
This seems to fix it:
proxyProvider: new ProxyProvider(
new Uri("https://proxy.server:port"),
"proxy_username",
"proxy_password"
)
I could've sworn whatever example I was using said to not include port. Apparently that was fallacious. Sorry for the trouble guys, but thanks for trying to help!
Also, verified that mkunzi's answer is valid too. You need the slashes at the end of the endpoints (e.g. "meta.v1/") or it won't work.
I'm trying to send a SOAP request to a 3rd party web service. I've successfully send and received data from other interfaces in the same service, but I'm having problems with this particular one:
<SP_GoodsMovement xmlns="http://services.hnseu.com">
<GoodsMoved xmlns="http://tempuri.org/SP_GoodsMoved.xsd">
<SerialNumberedGoodsMovements>
<SerialNumbered>
<PartNumber>string</PartNumber>
<SerialNumber>string</SerialNumber>
<MovementType>string</MovementType>
<FromLocation>string</FromLocation>
<FromLocationCategory>string</FromLocationCategory>
<ToLocation>string</ToLocation>
<ToLocationCategory>string</ToLocationCategory>
<AssetMovementTimestamp>dateTime</AssetMovementTimestamp>
<GoodsInReference>string</GoodsInReference>
</SerialNumbered>
<SerialNumbered>
<PartNumber>string</PartNumber>
<SerialNumber>string</SerialNumber>
<MovementType>string</MovementType>
<FromLocation>string</FromLocation>
<FromLocationCategory>string</FromLocationCategory>
<ToLocation>string</ToLocation>
<ToLocationCategory>string</ToLocationCategory>
<AssetMovementTimestamp>dateTime</AssetMovementTimestamp>
<GoodsInReference>string</GoodsInReference>
</SerialNumbered>
</SerialNumberedGoodsMovements>
<NonSerialNumberedGoodsMovements>
<NonSerialNumbered>
<PartNumber>string</PartNumber>
<Quantity>unsignedInt</Quantity>
<MovementType>string</MovementType>
<FromLocation>string</FromLocation>
<FromLocationCategory>string</FromLocationCategory>
<ToLocation>string</ToLocation>
<ToLocationCategory>string</ToLocationCategory>
<Used>boolean</Used>
<AssetMovementTimestamp>dateTime</AssetMovementTimestamp>
<GoodsInReference>string</GoodsInReference>
</NonSerialNumbered>
<NonSerialNumbered>
<PartNumber>string</PartNumber>
<Quantity>unsignedInt</Quantity>
<MovementType>string</MovementType>
<FromLocation>string</FromLocation>
<FromLocationCategory>string</FromLocationCategory>
<ToLocation>string</ToLocation>
<ToLocationCategory>string</ToLocationCategory>
<Used>boolean</Used>
<AssetMovementTimestamp>dateTime</AssetMovementTimestamp>
<GoodsInReference>string</GoodsInReference>
</NonSerialNumbered>
</NonSerialNumberedGoodsMovements>
</GoodsMoved>
</SP_GoodsMovement>
so my code is as follows (i can expand this if necesssary):
...
if (requestType == "SP_GoodsMovement")
{
GoodsMoved SOAP_GoodsMoved = new GoodsMoved();
SOAP_GoodsMoved.SerialNumberedGoodsMovements[0].PartNumber = partNumber[0].InnerXml;
...
string SOAPMessage;
SOAPMessage = request.SP_GoodsMovement(header, SOAP_GoodsMoved).Message;
}
When I run this code I get an 'Object reference not set to an instance of an object' error.
I think i'm not referencing the PartNumber parameter properly, but i've tried a few things without success.
Any ideas?
SOAP_GoodsMoved.SerialNumberedGoodsMovements[0]
doesn't appear to be initialised.
maybe try
GoodsMoved SOAP_GoodsMoved = new GoodsMoved();
SOAP_GoodsMoved.SerialNumberedGoodsMovements = new WhateverObject[1];
SOAP_GoodsMoved.SerialNumberedGoodsMovements[0] = new WhateverObject();
SOAP_GoodsMoved.SerialNumberedGoodsMovements[0].PartNumber = partNumber[0].InnerXml;
or you could right an overload for your GoodsMoved() ctor that ensures that the SerialNumberedGoodsMovements array gets initialized with a certain size.