Solved

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

Posted on 2011-03-14
16
425 Views
Last Modified: 2012-08-13
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
Comment
Question by:speedygonzalez
  • 7
  • 5
  • 4
16 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 223 total points
ID: 35129356
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
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 277 total points
ID: 35129499
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
 

Author Comment

by:speedygonzalez
ID: 35165498
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
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 223 total points
ID: 35165857
It depends entirely on what format the 3rd party service is expecting to receive.
0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 277 total points
ID: 35166705
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
 

Author Comment

by:speedygonzalez
ID: 35179578
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
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 223 total points
ID: 35179678
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
 

Author Comment

by:speedygonzalez
ID: 35180514
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 277 total points
ID: 35182174
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
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35182236
The blogspot article seems to imply that APEX requires the hard way
0
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 277 total points
ID: 35182261
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
 

Author Comment

by:speedygonzalez
ID: 35188506
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
 
LVL 60

Assisted Solution

by:Geert Bormans
Geert Bormans earned 277 total points
ID: 35188538
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
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 223 total points
ID: 35188540
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
 

Author Comment

by:speedygonzalez
ID: 35188651
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
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 35188653
welcome
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now