I am using a doc data payments gateway service and when I try to give it a request to create an order it throws the following exception:
XmlSerializer attribute
System.Xml.Serialization.XmlAttributeAttribute is not valid in
version. Only XmlElement, XmlArray, XmlArrayItem, XmlAnyAttribute and
XmlAnyElement attributes are supported when IsWrapped is true.
I don't think it is an exception that has anything to do with the service. What am I doing wrong on my side of implementation. Can anyone help me with that?
EDIT
I have used DocDataPayments gateway and used the wsdl refrence they give to make the call.
The create call I am making is as follows:-
PaymentServiceSOAPClient client = new PaymentServiceSOAPClient();
createSuccess success = new createSuccess();
client.create(merchant, strMTID, paymentPreferences, menuPreferences, shopper, totalGrossAmount, billTo, "description", "Thanks for your purchase", true, new paymentRequest(), new invoice(), new technicalIntegrationInfo(), Convert.ToDecimal(0.9), out success);
I think, you are using wcf default serializer to make proxy classes.you can try with DataContract serializer instead default serializer.
Related
I'm tring to use restsharp in F# to call the Mailgun API.
I modelled it on the sample C# code from Mailgun but I can't get it going.
The problem code is:
let client: RestClient =
new RestClient(
BaseUrl = Uri("https://api.mailgun.net/v3")
)
client.Authenticator = new HttpBasicAuthenticator("","")
This expression was expected to have type IAuthenticator' but here has type 'HttpBasicAuthenticator'
It seems that somehow the inherited type for one is different than the expected type which doesn't make sense to me. The HttpBasicAuthenticator object says it inherits from authentocatorBase
I haven't tested it, but most likely you have to cast the new object to the interface. F# requires it.
client.Authenticator = new HttpBasicAuthenticator("","") :> IAuthenticator
Have a look at https://fsharpforfunandprofit.com/posts/interfaces/
i am trying to connect sapui5/openui5 ODataModel to an odata-server. I want to use a nodejs server with package simple-odata-server. Unfortunately this odata server provides metadata only in xml-format. But sapui5 tries to load metadata in json-format.
Before i switch to another odata server, i want to check, wether sapui5 can load metadata in xml-format. I tried to create the model with several parameters, but ODataModel still tries to load metadata as json.
var oModel = new ODataModel("/odata", {
"metadataUrlParams": "$format=xml",
"json": false
});
Does anybody know, wether i can switch to $format=xml
Thanks in advance,
Torsten
As far as I know the OData protocol metadata is always provided as XML, never seen metadata in JSON format. Also my n-odata-server Qualiture mentioned in the comment above does it. But I never had problems with SAPUI5. It requests the metadata, gets the xml stream and works with it.
Since the metadataUrlParams parameter is of type map I'd suppose it would at least do what you intend like this:
var oModel = new ODataModel("/odata", {
"metadataUrlParams": {
"$format": "xml"
}
});
https://sapui5.hana.ondemand.com/sdk/#docs/api/symbols/sap.ui.model.odata.ODataModel.html#constructor
So as recommended I'd like to use RestSharp to handle REST web service. I am developing iOS and Android application and I would love to make PCL that makes requests to the service and just returns parsed results (eg. array of User objects).
So how do I get RestSharp in my PCL, tried NuGet, components are not for PCLs and seriously bad would be to just download source files and copy them in the project, I want to keep some dependency management in place.
What is the best practice? Am I looking at this problem at wrong angle?
RestSharp doesn't support PCLs. I'd suggest checking out PortableRest, or just using a combination of HttpClient and Json.NET.
I use dependency injection so I can support non-PCL JSON parsers. I also plan to give the native HttpClient wrappers from the component store a try. By using non-PCL code you will gain quite a lot in performance compared to Json.NET etc.
Link to source code
Text library has serializer interfaces, Web has the IRestClient.
Modern HTTP Client from the component store.
Below modifications worked for me and will be glad if it works out to you.
Try using modernhttpclient in your PCL. And inAndroid project ensure you have the below packages.
Microsoft.Bcl.Build
Microsoft.Bcl
Microsoft.Net.Http
modernhttpclient
Along with that in application manifest under required permissions give permissions to the below.
Access_Network_State
Access_wifi_state
Internet
Ideally when you try to add Microsoft.Bcl into your Android project targettting monoandroid it will throw out error, so try to add the nuget refrence in the above order.
I developed a really simple REST client to perform Http requests easily. You can check it on my Github repo. The API is really simple:
await new Request<T>()
.SetHttpMethod(HttpMethod.[Post|Put|Get|Delete].Method) //Obligatory
.SetEndpoint("http://www.yourserver.com/profilepic/") //Obligatory
.SetJsonPayload(someJsonObject) //Optional if you're using Get or Delete, Obligatory if you're using Put or Post
.OnSuccess((serverResponse) => {
//Optional action triggered when you have a succesful 200 response from the server
//serverResponse is of type T
})
.OnNoInternetConnection(() =>
{
// Optional action triggered when you try to make a request without internet connetion
})
.OnRequestStarted(() =>
{
// Optional action triggered always as soon as we start making the request i.e. very useful when
// We want to start an UI related action such as showing a ProgressBar or a Spinner.
})
.OnRequestCompleted(() =>
{
// Optional action triggered always when a request finishes, no matter if it finished successufully or
// It failed. It's useful for when you need to finish some UI related action such as hiding a ProgressBar or
// a Spinner.
})
.OnError((exception) =>
{
// Optional action triggered always when something went wrong it can be caused by a server-side error, for
// example a internal server error or for something in the callbacks, for example a NullPointerException.
})
.OnHttpError((httpErrorStatus) =>
{
// Optional action triggered when something when sending a request, for example, the server returned a internal
// server error, a bad request error, an unauthorize error, etc. The httpErrorStatus variable is the error code.
})
.OnBadRequest(() =>
{
// Optional action triggered when the server returned a bad request error.
})
.OnUnauthorize(() =>
{
// Optional action triggered when the server returned an unauthorize error.
})
.OnInternalServerError(() =>
{
// Optional action triggered when the server returned an internal server error.
})
//AND THERE'S A LOT MORE OF CALLBACKS THAT YOU CAN HOOK OF, CHECK THE REQUEST CLASS TO MORE INFO.
.Start();
I set up my odata service with Node, MongoDB and JayData. When I hit http://localhost:8000/odata/findash.svc/$metadata in my browser I get the metadata exactly as I would expect.
In the browser console I execute this sample code:
var manager = new breeze.EntityManager('odata/findash.svc');
var query = new breeze.EntityQuery()
.from("accounts");
manager.executeQuery(query).then(function(data){
console.log(data);
}).fail(function(e) {
alert(e);
});
An alert pops up with the message: Error: Metadata query failed for: odata/findash.svc/Metadata; Not Found
The net tab confirms that Breeze is hitting odata/findash.svc/Metadata which produces a 404 instead of odata/findash.svc/$metadata which works fine.
Is there a way to configure this behavior in Breeze or is the problem with my odata setup?
I assume that you meant OData and not JayData in your question. Breeze and JayData are two different products. If not then I'm not sure I understand the question.
I think that you haven't told breeze to use the OData endpoint. By default breeze uses a WebApi endpoint. You can change this via the breeze.config like this:
breeze.config.initializeAdapterInstances({
dataService: "OData", ...
});
Breeze supports both OData and a WebApi endpoints. The OData endpoint ( per the OData spec) returns metadata from '$metadata". The webApi endpoint returns metadata from 'Metadata'.
See: http://www.breezejs.com/documentation/odata
In case of a system error from the GradesManagementService, the returned response object is null, but the response header includes the diagnostic information. What class do I use to get this information?
Here is my code:
GradesManagementServiceV10 port = service.getGradesManagementServiceV10();
GetGradeValuesByOrgUnitRequest r = new GetGradeValuesByOrgUnitRequest(); GetGradeValuesByOrgUnitResponse resp = new GetGradeValuesByOrgUnitResponse(); WSBindingProvider bp = (WSBindingProvider)port; bp.setOutboundHeaders( Headers.create(formatSOAPHeader())); ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, getUrl());
resp = port.getGradeValuesByOrgUnit(r); // the response is null. <------ How do I see what the error is?
In your service object (in the above code snippet that would be port, the object of the Web service proxy class GradesManagementServiceV10), ResponseHeader property would contain such information (this property's type is ResponseHeaderInfo).
If you are doing new development with Desire2Learn I would also suggest that you look at the Valence REST/JSON API. New features and new API calls are going to show up in that system http://docs.valence.desire2learn.com/ (it is always deployed, the docs are open, etc.)