I have a web service project containing 3 web services (which require no input parameters) but which I need to schedule to be called once every night. To achieve this I have done some Googling and created a console application to call the web services, which I should now be able to schedule with Windows Task Scheduler.
I am a total novice at writing console apps and have only a tiny bit of experience with VB.NET, but I achieved what I needed in the console app by entering a web reference to the web service, then applying the following simple code:
Sub Main()
Dim wscall As New EmployeeEmailWS
wscall.UpdateAbsenceTables()
wscall.GetThreePeriodsInAYear()
wscall.GetSixDaysInAYear()
End Sub
This simply triggers the three web services to run successfully.
However, having got this far, I would really like also to somehow read in the Soap web service response so that I can write it into a database as a log of each result.
The response message is as simple as the following (from SoapUI), but I just don't know how to obtain it:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<UpdateAbsenceTablesResponse xmlns="http://www.ernspnamespace7.co.uk/EmployeeWS">
<UpdateAbsenceTablesResult>
<ResponseCode>00001</ResponseCode>
<ResponseDescription>Absence Tables Successfully Updated</ResponseDescription>
</UpdateAbsenceTablesResult>
</UpdateAbsenceTablesResponse>
</soap:Body>
</soap:Envelope>
Can anybody please point me in the right direction for how to obtain this response into my console app. Particularly if I could somehow get the values of ResponseCode & ResponseDescription and convert them into Strings then I would be back in familiar territory for my basic knowledge.
Thanks.
Never mind.
It suddenly occurred to me that I could just add some code to the end of the web services to write their output to a database table every time they are called. That avoided the need to bother with the XML altogether.
Related
In my winrt app, I am trying to update the live tile based on polled URIs. There is currently no update happening and I can't figure out how to troubleshoot. There are numerous scenarios that could be breaking things but i can't seem to find anyway to get insight into potential errors.
The TileUpdateManager seems to be a bit of a black hole that absorbs information but never lets it out.
Does anyone know of how to view errors from the TileUpdateManager?
If it interests anyone, here is my update code:
TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true);
PeriodicUpdateRecurrence recurrence = PeriodicUpdateRecurrence.HalfHour;
List<Uri> urisToPoll = new List<Uri>();
urisToPoll.Add(new Uri(#"http://livetileservice2012.azurewebsites.net/api/liveupdate/1"));
urisToPoll.Add(new Uri(#"http://livetileservice2012.azurewebsites.net/api/liveupdate/2"));
TileUpdateManager.CreateTileUpdaterForApplication().StartPeriodicUpdateBatch(urisToPoll, recurrence);
To expand on Nathan's comment, here are two steps you can take to troubleshoot:
Enter your URI straight into a browser to see the results that are returned, and inspect them for being proper XML. As Nathan points out, your URIs are returning JSON which will be ignored by the tile update manager. As a working example (that I use in Chapter 13 of my HTML/JS book), try http://programmingwin8-js-ch13-hellotiles.azurewebsites.net/Default.cshtml.
If you feel that your URI is returning proper XML, try it in the Push and Periodic Notifications Sample (Scenarios 4 and 5 for tiles and badges). If this works, then the error would be in your app code and not in the service.
Do note that StartPeriodicUpdate[Batch] will send a request to the service right away, rather than waiting for the first interval to pass.
Also, if you think that you might have a problem with the service, it's possible to step through its code using Visual Studio Express for Web running on the localhost, when the app is also running inside Visual Studio Express for Win8 (where localhost is enabled).
.Kraig
I'm trying to upload a file to SharePoint programmatically via a Mac Application that I am currently writing. I can use the GetListItems webservice to retrieve a list of files, and all authentication etc works correctly. I form the SOAP message myself as follows:
At first I thought I just had the Objective C side written incorrectly, but I've been using the HTTP request extension for Firefox, 'Poster', and still can't get it to work.
The soap message in Poster that I construct is:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<CopyIntoItems xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<SourceUrl>http://null</SourceUrl>
<DestinationUrls>
<string>myurl.com/Shared Documents/Documents/TestingFile.txt</string>
</DestinationUrls>
<Stream>VGVzdGluZyB0ZXN0aW5n</Stream>
</CopyIntoItems>
</soap:Body>
</soap:Envelope>
The stream (at the moment) is just some data, to see if I can get it to work. I read that setting the SourceUrl as http://null, can help in some instances. I also read that the DestinationURL needs to be the full path. The problem here is:
1) If I put the URL without https:// then I get a response of:
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><CopyIntoItemsResponse
xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<CopyIntoItemsResult>0</CopyIntoItemsResult><Results><CopyResult ErrorCode="Success"
DestinationUrl="myurl.com/Shared Documents/Documents/TestingFile.txt" /></Results>
</CopyIntoItemsResponse></soap:Body></soap:Envelope>
2) If I put the full path, e.g.
https://myurl.com/Shared Documents/Documents/TestingFile.txt
then the result tells me the same as before, except for this bit:
<CopyResult ErrorCode="Unknown" ErrorMessage="Object reference not set to an instance of an
object."
DestinationUrl="https://dbp.btfinancialgroup.com/Shared%20Documents/Papers/TestingFile.txt"
/>
3) If I put the full path, in quotes, e.g.
"https://myurl.com/Shared Documents/Documents/TestingFile.txt"
then the results tell me the same as the first, e.g. that it was successful, but with
a destinationURL of this:
DestinationUrl=""https://dbp.btfinancialgroup.com/Shared
Documents/Papers/TestingFile.txt""
In ALL of these scenarios, the file does not exist in the destination at the end of the request.
I'm really stuck, as most online suggestions are for remedying C# problems, which use the .net protocols for connecting to SharePoint.
Any suggestions?
Thanks
To assist in anyone else who may come across this problem.
It turned out not to be an issue with my code at all, which I established by making a C# project to try and use the better connectivity it provides to SharePoint, and also spoke to someone in Microsoft Support who confirmed my code should work.
In the end, it was incorrect mappings on the server, which meant the web service never linked correctly to the URLs. This caused the "Object reference not set to an instance of an object" error.
To anyone else receiving this error message, it may not lie just in a problem with the values you are passing to the web service - also check the mappings set up on the server. Apparently the ULS logs may help with this, the Microsoft support guy mentioned, in terms of narrowing down what's causing it.
I am creating a REST web service that returns XML documents by serializing .NET objects using the DataContractSerializer. It works very nicely returning documents like:
<?xml version="1.0" encoding="utf8" ?>
<patient xmlns="http://stackoverflow.com/example">
.....
</patient>
by using code like this:
Message MyRestMethod()
{
Patient patientObject = new Patient() {Name="Mickey Mouse"};
Message message = WebOperationContext.Current.CreateXmlResponse<Patient>(patientObject);
return message;
}
However sometimes, the web service is used by a web browser, and so it would be much nicer if it would return documents like this:
<?xml version="1.0" encoding="utf8" ?>
<?xml-stylesheet type="text/xsl" href="/stylesheet/format.xsl" ?>
<patient xmlns="http://stackoverflow.com/example">
.....
</patient>
I have done some substantial digging around, and can almost do it by deriving my own message and overiding OnWriteBodyContents() to get access to the XmlDictionaryWriter. At this point, I then discovered that WriteProcessingInstruction(name, text) not able to write xml-stylesheet instructions.
More importantly, WCF client code receiving an xml-stylesheet processing instruction also bombs out, so even if you "hack" the stream at the character level to add it, it would need not to be sent to WCF clients...
If anyone has a better suggestion, please let me know...
Having dome some substantial reading on this, the answer is that it is not sensible to add an xml-stylesheet marker in the XML being returned to the WCF client.
The markers are processing instructions, which instruct the interpreter to process the XML document in a certain way. In this particular case by applying an XSLT to the document. the WCF serialisation and deserialiser both reject XML with stylesheet processing instructions, which makes sense - as in the WCF client case you do not want the processing instruction to be followed.
However, for my usecase, having the stylesheet processing instruction in when the xml is returned to a browser does make sense, so I have solved my problem by doing a conditional serialisation based on the UserAgent in the request, and in the case of it not being the WCF client application, I am adding the stylesheet to the stream thats used to create the response message.
In such case you are most probably going to to custom message encoder because xml declaration is added by message encoder and it doesn't provide any features to add any other directives.
I’m using Coldfusion 9,0,0,251028 on Windows 7 64-bit.
I'm trying to change credit card processors for a website. I've read the integration guide for the Web Service API v 4.0, but it doesn't give me much in the way of how I integrate with coldfusion to build the xml that gets enclosed in SOAP and sent.
I've talked to Firstdata's second level support and was told they don't help with programming beyond troubleshooting error codes. They also told me they have no forum concerning the web service API.
What kind of tags in coldfusion would I use to start this transaction? Does anyone know where I could find an example or instructions besides the web service api integration guide?
Here's some recommended reading on doing SOAP with ColdFusion:
Making SOAP Web Service Requests With ColdFusion And CFHTTP
SOAP Request Functions
Troubleshooting SOAP Requests and Responses
I've always found SOAP to be a pain in the ass, but if that's the only way to go, the three links above should get you there.
You will want to look at cfobject and cfinvoke. I assume you have the WSDL url, so the first thing I would do is try that like this:
<cfobject webservice = "WSDL URL" name = "testCall" />
<cfdump var="#testCall#"/>
This should show you the available methods. Then you would call those message using cfinvoke:
<cfinvoke webservice = "#testCall#" method = "methodName" returnvariable="returnData" />
Then you could use the return data however you need. But a god start is to just dump it out and see what it looks like.
<cfdump var="#returnData#" />
I'm pushing the bounds of what one should ask of others with this one, but I'm totally stuck, so here goes...
This is my first web service. Not only that, it's my companies first web service - nobody I work with has ever written or consumed anything like this one. I know these things are not complicated, but for a first kick at the can, this is killing me because the API is so large.
WSDL is here: https://fast.uspspostalone.com/USPSMLXMLWeb/services/UspsMailXmlMailingServices/wsdl/UspsMailXmlMailing70.wsdl
I need to get a "FullServiceNixieDetail". Should be an XML doc. The documentation provided by USPS says I need to invoke FullServiceNixieDetailQueryRequest, and I will get back a FullServiceNixieDetailQueryResponse, which contains a FullServiceNixieDetail.
I cannot for the life of me get anything that seems to work. The code I currently have is:
Imports USPSACSProcessor.UPSPMailXML
Dim c As New UspsMailXmlMailingServiceClient
Dim request As New FullServiceNixieDetailQueryRequest
Dim response As FullServiceNixieDetailQueryResponse
'Assume I populate the Request object correctly here
response = c.FullServiceNixieDetailQuery(request)
But my response object has no FullServiceNixieDetail. Just a bunch of summary properties like TotalMessageCount etc.
How do I get my FullServiceNixieDetail XML?
Did you populate your request with the proper authentications?
I suspect it is the response.Item that is the FullServiceNixieDetail, but without the usage knowledge of this particular web service, it's hard to confirm, you will need to find this out from the service host. You can also try doing a cast on the item to FullServiceNixieDetail, to verify this.