• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 447
  • Last Modified:

Can an XML Document/Data Be Sent As A URL Querystring?

Hi,  As per my question title can data stored in xml format be passed as a url querystring? if so is this ok to use or bad practice?

Thanks.
0
speedygonzalez
Asked:
speedygonzalez
  • 7
  • 5
  • 4
9 Solutions
 
Carl TawnSystems and Integration DeveloperCommented:
It's generally a bad practice. It is technically possible, but the querystring has a fairly short length limit that varies between browsers (maximum i believe currently is 8142 characters)
0
 
Geert BormansInformation ArchitectCommented:
Most webservices protocols have XML as the query request payload (XML-RPC, SOAP, ...)
That is done as the body of a POST request
That is not really part of the request URL string (it is the body instead of the header)
So consider it an alternative suggestion.

I would definitely put the request XML as part of the request body and use POST.
You are then also not bothered by the fact that you need to do URL encoding on an XML snippet
0
 
speedygonzalezAuthor Commented:
Hi all, Thanks all for the help.

if using a web service instead of a querystring. When passing my data from my webserice to a 3rd party webservice via a method call would I need to send it as a specific XML object or would it be ok to just format my data as a string of XML data?

Thanks again.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
Carl TawnSystems and Integration DeveloperCommented:
It depends entirely on what format the 3rd party service is expecting to receive.
0
 
Geert BormansInformation ArchitectCommented:
It is very unlikely that you can send a random XML to your service.
You will need to check the web service description
for a SOAP service that will mean evaluating the WSDL,
for a REST service that would mean reading the manual
0
 
speedygonzalezAuthor Commented:
Hi all, thanks for the help.

Gertone, having received some more information on my project requirements I think you are right that I use SOAP as part of my process.

if I have the following wsdl requirements

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Header>
    <ServiceAuthHeader xmlns="http://testServer/testData">
      <Username>string</Username>
      <Password>string</Password>
    </ServiceAuthHeader>
  </soap12:Header>
  <soap12:Body>
    <create_account xmlns="http://testServer/testData">
      <packet>
        <ID>string</ID>
        <FirstName>string</FirstName>
        <LastName>string</LastName>
      </packet>
    </create_account>
  </soap12:Body>
</soap12:Envelope>

Would I need to build my data as XML first of all using something like the following

    XmlStreamWriter dataPackage = new XmlStreamWriter();
    dataPackage.writeStartDocument('utf-8','1.0');
      dataPackage.writeStartElement('http://www.w3.org/2001/XMLSchema-instance', 'http://www.w3.org/2001/XMLSchema', 'http://www.w3.org/2003/05/soap-envelope');

Then pass it to the web service method via SOAP?

If it is correct that I create the data to send via SOAP using XML as above then what would my next elements be to write to my xmlStreamWriter?

Thanks for your help. Note I'm very new to web services so apologies if what I've detailed/questioned is completely wrong!!!
0
 
Carl TawnSystems and Integration DeveloperCommented:
Are you talking to your web service through an .Net application? Have you added as web reference to the service? If you have then you shuold have a proxy class for the service. You create an instance of that and call the methods directly as if it were any other object. The proxy class takes care of wrapping the procedure calls in soap messages for you.
0
 
speedygonzalezAuthor Commented:
Hi carl_tawn,

I will be using Salesforce.com's apex language.

From looking at the following websites http://salesforcetrekbin.blogspot.com/2010/04/call-external-web-service-from.html and http://wiki.developerforce.com/index.php/Apex_Web_Services_and_Callouts a HttpRequest object may be able to be used. Otherwise I'm not sure if another method exists also within apex.

Is the HttpRequest object used for RESTful web services only or do you think I can use it calling a SOAP web service? I note REST based has been mentioned in the 2 web pages above.

Thanks again!
0
 
Geert BormansInformation ArchitectCommented:
There are basically two ways how programming languages deal with SOAP services

1. Have a SOAP library, which allow you to make simple method call and under the hood all is translated into a SOAP request.
No need to say that if available this is by far the easiest way of dealing with SOAP

2. HAve no SOAP provissions at all, but have the ability to make a HTTP request
Then creating the SOAP envelope is a burden for the programmer, who creates a correct SOAP XML and POSTs it to the SOAP access point

I have no clue if APEX can do SOAP calls,
If not simply POST the above SOAP example (which is not a WSDL by the way) to the SOAP access point
0
 
Geert BormansInformation ArchitectCommented:
The blogspot article seems to imply that APEX requires the hard way
0
 
Geert BormansInformation ArchitectCommented:
ignore the blogspot article,
the second article explains you how to import a WSDL and make a call. All you need is there
good luck
0
 
speedygonzalezAuthor Commented:
Hi Gertone,

Thank you. I had not realised that I could just import a wsdl file & it would create my methods. I guess I should get the correct wsdl file therefore.. One further question I have though. I will be posting data to the 3rd party server & only receiving one string value in return. By importing a WSDL I presume I can create "response" methods in my class from it as opposed to just "request" methods alone?

Thanks again!
0
 
Geert BormansInformation ArchitectCommented:
A WSDL describes the interface of the SOAP service
(actually it is some sort of standardized API description)

It defines what a message should look like for a request, and then it also shows how the response looks like
you don't really "create" response classes.
you will likely "get" response classes by importing the WSDL

I suggest that you get the WSDL and import it and see what you get
0
 
Carl TawnSystems and Integration DeveloperCommented:
SalesForce provide details of how to obtain the correct WSDL and generate the proxy in Visual Studio:

    http://www.salesforce.com/us/developer/docs/api/index.htm

The proxy class takes care of packaging and sending the SOAP request, and also handling the response. You just need to create an instance of the proxy class and call methods on it as you would with any other object.
0
 
speedygonzalezAuthor Commented:
Thanks guys, all of this has been very helpful. As you will have guesed I didn't really understand what some of the terminology meant even from the salesforce guides, but with your suggestions & advice I think i understand it clearer now.

Will share out the points!

Thanks again.
0
 
Geert BormansInformation ArchitectCommented:
welcome
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 7
  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now