I am not expert of Internet communication protocols. Normally I develop some WebServices in c#, for my needs. My functions are developed with the [WebMethod] keyword and return numbers, for example two coordinates.
To call the WebService, for example with a browser, I write:
https://www.mysite.xx/MyWebService.asmx/MyWebMethod?Request=..Parameters ...
And I get an answer like:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">-102866,667000005;-92718,2779999226</string>
Till to day, calling the WebService with programs, I process the above answer, to get what I need, i.e. just the two numbers. I would like to know whether it is possible to simply get an answer with the two numbers only, without the other stuff.
Related
First off a little context, I work for a channel manager company that builds custom endpoints for their clients to talk to. We currently mostly code in c#.
This is the first time we are connecting with a client that asked us to support a soap web service.
Sadly, we don't have previous experience in this and I can't find any concrete explanations to what it looks like to support a SOAP call.
Currently, it looks like that I have to simply use text processing methods to run through the received XML and parse it in a non-generic way.
But this feels like there should be a more straightforward approach since the protocol is almost 20 years old.
For almost every search result I only get examples of what the XML looks like, but what I'm interested in, is what I need to implement in my application to host an endpoint for the client to successfully post and receive a SOAP message from. And if there is a way to do this without something like XmlWriters/Readers.
Anything to help me get on my way mary is appreciated!
Greetings, Davey
WCF is the least outdated library for offering SOAP.
When you can define the contracts then you're in luck, that's just writing a C# interface.
But when necessary you can also import WSDL specifications and generate C# from that.
it looks like that I have to simply use text processing methods to run through the received XML and parse it
Don't even consider that. Everything is under control of schemas. And you will also have to generate valid return packages.
We have a asmx web service that are used by hundreds of customers. We recently did some refactoring including an upgrade to .NET 4.0.
We tested the refactored version by doing a lot of request using data from our logs as parameters and compared the raw result of the old and refactored web service. The only difference we found was that the namespace of the result was in another order. Note that old and refactored web service were on different servers. Different order of the namespace seems safe to release so that was what we did...
Today I was contacted by a customer telling me that they were unable to read our result and pointing this namespace issue as the reason. This seems very strange to me since they must have a more or less corrupt XML parser to get an issue like this. I would however try to isolate this, since we loose a lot of money every hour.
I reverted our project back to .NET 3.5 but get the same namespace order. But there seems to be a difference of the namespace order between the servers.
Does anyone know why the order is different? Does it have to do with .NET version, version of other components or is it just random?
From server one:
<?xml version="1.0" encoding="utf-8"?>
<result xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://mydomain.com/">
...
From server two:
<?xml version="1.0" encoding="utf-8"?>
<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://mydomain.com/">
...
I'm a bit stuck...
I have never so much as successfully loaded an xml document in WebMatrix (or JavaScript for that matter), despite how many times I have tried.
No online example is complete or accurate.
if I had an xml file that contained this (and only this):
<?xml version="1.0" encoding="utf-8" ?>
<someNode>
<someValue>HEY THERE! I'M XML!</someValue>
<someValueTwo>Another Value</someValueTwo>
</someNode>
How could I (start from loading the xml document etc.) plot the values of the two elements on one of my WebMatrix pages (please include where the code you are providing goes, as I have no clue).
Please include all the places I would need the code not just loading or writing to page.
*******UPDATE:******
Oh, well, nvm, xml is useless anyway, I'll just use another database or render the contents of another external cshtml page or something.
I have looked at XPath before and such, but I am not really worried about selecting them by tagname, id, attribute, etc because researching that would have been easy.
Sometimes I wonder why XML is still around...(Yes, I know it (is supposed to) help communicate data across very different languages and platforms) but the truth is, even with online tutorials and walkthroughs, it doesn't work, and it doesn't seem like there's anyone left who does know how to do this really. Why is it still around? Isn't it time that WebMatrix got rid of the xml based methods, since they don't work, and since there isn't anyone left who knows how to so much as try to load an xml file without getting errors?
Just curious if xml will be faded out in future updates.
*******UPDATE:******
Okay, I'm told that xml is supposed to still be useful. Do you just have to not be me to get it to work, lol?
I've never done anything with WebMatrix so I'm not gonna have much to say on that front. I am however confused by your attitude toward XML. If you mean only that XML is not useable in the WebMatrix context I can neither confirm nor deny that; however XML is dead useful in a plethora of other scenarios, and it is unclear from your question if you know that or not. Sorry I can't help on your question, just clarifying that XML is a very powerful tool as far as data file formats are concerned.
Recently I have been thinking combining C# applications with a website, so that we can run multiple threads in C# and complete more tasks in the time it would take PHP would to do 1.
Most of us know that PHP Runs on a single thread and therefor we cant do multiple actions at the same time
But it would be nice if we can do something like:
$SharpEntity = new CSharpExecute();
$SharpEntity->add("downloader.class http://server.com/file.ext");
$SharpEntity->add("downloader.class http://server.com/file2.ext");
$SharpEntity->add("downloader.class http://server.com/file3.ext");
$SharpEntity->initialize();
while($SharpEntity->completed === false)
{
$SharpEntity->Update();
}
echo 'Files Grabbed';
This is just a basic example but would it actually be possible to do such a thing and if so, how can you do this?
I know that Facebook and other large systems do something like this but with C++, what you guys think?
A strategy similar to JSON (or json itself)
break the objects down to strings and map it to a C# object.
If you go with JSON it self you can get away with using some of the C# helpers already provided for translating Json.
Hope that helps.
We have a customer that is trying to call our web service written in C# from PHP code. The web service call takes a long as parameter.
This call works fine for other customers calling from C# or Java but this customer is getting an error back from the call. I haven't debugged their specific call but I am guessing that the 64bit integer is getting truncated somehow from PHP. The customer says they are just making the web service call with a string but is there a wrapper in PHP that does type conversion. Could this be losing the number information?
Thanks for any info.
Most PHP installations won't support 64 bit integers - 32 is the max. You can check this by reading the PHP_INT_SIZE constant (4 = 32bit, 8 = 64bit) or read the PHP_INT_MAX value.
<?php
echo PHP_INT_SIZE, "\n", PHP_INT_MAX;
?>
If the web service class he is using is trying to type-convert a string representation of a 64 bit integer, then yes, it's mostly likely being truncated or converted into a float. You can sort of see this behavior with this simple test
<?php
echo intval( "12345678901234567890" );
// prints 2147483647, the max value for a 32 bit signed int.
Without knowing the details of his implementation, it's difficult to postulate on what a good solution/workaround might be.
If you absolutely must take a big number like that, make it a string, and convert it to long in your web service.
This will bother your other users a little bit, but would make it more friendly to your PHP-using costumers.
PHP brutally murdered its integer support, to the point where you have no predictable way of knowing it a specific install will handle 32-bit or 64-bit integers.
The easiest way to handle this would be to expose a new endpoint that takes a string, and just cast it on your end.
For reference on PHP's epic fail:
http://www.mysqlperformanceblog.com/2007/03/27/integers-in-php-running-with-scissors-and-portability/
I wrote an article regarding PHP using nuSoap to call a C# web service... Haven't yet encountered the issue with long int conversions, but I will definately be running some tests to see if I should add it into my article. Thanks, Sean
http://seanmcilvenna.com/blog/7-general/24-windows-php-development