How to create a SOAP request with JavaScript for Acrobat Pro 9

Hi all,

I've created a soap request using the soap.connect method - but what I really need is a way to create a soap request with the soap.request method. I need to pass authentication, and this seems to be the only way to pass in the oAuthenticate object.

Does anyone know how I can create the code for this - using a weather wsdl as an example here is my connect code:

      var strURL = "http://www.webservicex.net/globalweather.asmx?wsdl";
      var service = SOAP.connect(strURL);
      var sCountryName = "United States";
      var sCityName = "New York";
      var result = {
                  soapType: "xsd:string",
                 CountryName: sCountryName,
                   CityName: sCityName
                   //soapValue:
                  };
      var results = service.GetWeather(result);
      app.alert(results);

This works fine - however I want to do something like this for the soap.request

var myURL = "http://www.webservicex.net/globalweather.asmx?wsdl";
var echoStringRequest = {
"http://www.webservicex.net/globalweather.asmx/GetWeather" {
CityName: "New York"
CountryName: "United States"

}
};

var mySOAPAction = "http://www.webservicex.net/globalweather.asmx";


var response = SOAP.request ({
cURL: myURL,
oRequest: echoStringRequest,
cAction: mySOAPAction
});


var responseString = "http://www.example.com/methods:echoStringResponse";
var result = response[responseString]["return"];

console.println("Result is " + result);

However, i'm getting this error:

missing : after property id
3:Console:Exec
undefined

I dont think my code is right - and there is not much resources out there. Can anyone help please? Or if anyone knows how to write an async version?

lp84Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
After CityName: "New York"

you miss somes commas no ?
Replace :
var myURL = "http://www.webservicex.net/globalweather.asmx?wsdl";
var echoStringRequest = {
"http://www.webservicex.net/globalweather.asmx/GetWeather" { // <----- here
CityName: "New York" // <----- here
CountryName: "United States"

}
};

By :
var myURL = "http://www.webservicex.net/globalweather.asmx?wsdl";
var echoStringRequest = { "http://www.webservicex.net/globalweather.asmx/GetWeather", { CityName: "New York", CountryName: "United States" } };

Open in new window

0
leakim971PluritechnicianCommented:
Check this page too :


http://www.verydoc.com/documents/acrojsguide/pg_0254.htm

Open in new window

0
lp84Author Commented:
still having the same error. Do you know how I can setup the syntax? - that page is a bit confusing, in terms of syntax. Just need some proper working examples to follow. thanks a lot though.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

leakim971PluritechnicianCommented:
What about :


var myURL = "http://www.webservicex.net/globalweather.asmx?wsdl";
var echoStringRequest = { cURL:"http://www.webservicex.net/globalweather.asmx/GetWeather", oRequest:{ CityName: "New York", CountryName: "United States" } };

Open in new window

0
leakim971PluritechnicianCommented:
>that page is a bit confusing, in terms of syntax. Just need some proper working examples to follow. thanks a lot though.
page 664 here : http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf
0
leakim971PluritechnicianCommented:
the example with SOAP.request start at page 670
0
lp84Author Commented:
SOAPError: System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://www.webservicex.net/globalweather.asmx.
   at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
   at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
   at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
SOAP.request:13:Console undefined:Exec

undefined

Bit closer...

I actually am on that PDF - that is what i used to follow
0
lp84Author Commented:
Still trying a simple synchronous request and I cant see mto get past the http header error
0
mohan_sekarCommented:
Do you just want to know how to make an aync SOAP call?
0
leakim971PluritechnicianCommented:
You get the last error after following example on page 664 ?
0
lp84Author Commented:
well I was trying to do the synchronous way thinking it would be easier - but I cannot even do that. If you can show me how to do the async one that will be very appreciated.

No I wasn't sure how to setup the header..tried a few times but kept getting undefined errors
0
leakim971PluritechnicianCommented:
0
leakim971PluritechnicianCommented:
The following :


var cURL = "http://www.webservicex.net/globalweather.asmx";
var oRequest = {"http://www.webserviceX.NET:GetWeather":{CityName:"New York",CountryName:"United States"}};
var cAction = "http://www.webserviceX.NET/GetWeather";
var ver = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,bEncoded:false,cVersion:ver});

Open in new window

0
leakim971PluritechnicianCommented:
produce :


<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<SOAP-ENV:Body>
		<ns0:GetWeather xmlns:ns0="http://www.webserviceX.NET">
			<CityName>New York</CityName>
			<CountryName>United States</CountryName>
		</ns0:GetWeather>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Open in new window

0
leakim971PluritechnicianCommented:
A good one :


<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<SOAP-ENV:Body>
		<ns0:GetWeather xmlns:ns0="http://www.webserviceX.NET">
			<ns0:CityName>New York</ns0:CityName>
			<ns0:CountryName>United States</ns0:CountryName>
		</ns0:GetWeather>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Open in new window

0
leakim971PluritechnicianCommented:
The following "run" fine because the parameter "name" is optional :


//
var cURL = "http://www.guru4.net/articoli/javascript-soap-client/demo/webservicedemo.asmx";
var oRequest = {"http://www.guru4.net:HelloTo":{name:"leakim971"}};
var cAction = "http://www.guru4.net/HelloTo";
var cVersion = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,bEncoded:false,cVersion:cVersion});
app.alert(response);

Open in new window

0
leakim971PluritechnicianCommented:
The response is not the good :

(return "Hello !" and not "Hello leakim971!")
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<HelloToResponse xmlns="http://www.guru4.net/">
			<HelloToResult>Hello !</HelloToResult>
		</HelloToResponse>
	</soap:Body>
</soap:Envelope>

Open in new window

0
lp84Author Commented:
Thanks Leakim! They both work well!

One last question. I went thru the java doc for acrobat and used the oAuthenticate object to add in the authentication header, did it for both examples:

var oAuthenticator ={ Username: "test", Password: "test"};
var cURL = "http://www.webservicex.net/globalweather.asmx";
var oRequest = {"http://www.webserviceX.NET:GetWeather":{CityName:"New York",CountryName:"United States"}};
var cAction = "http://www.webserviceX.NET/GetWeather";
var ver = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,oAuthenticate:oAuthenticator,bEncoded:false,cVersion:ver});

var oAuthenticator ={ Username: "test", Password: "test"};
var cURL = "http://www.guru4.net/articoli/javascript-soap-client/demo/webservicedemo.asmx";
var oRequest = {"http://www.guru4.net:HelloTo":{name:"leakim971"}};
var cAction = "http://www.guru4.net/HelloTo";
var cVersion = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,oAuthenticate:oAuthenticator,bEncoded:false,cVersion:cVersion});
app.alert(response);

I am wondering if that will work for NTLM?
0
leakim971PluritechnicianCommented:
page 550 set UsePlatformAuth to true
So you don't need  Username and Password are ignored.

0
lp84Author Commented:
Awesome!! Like this? I ran it, seems to work



var oAuthenticator ={ UsePlatformAuth: "true"};
var cURL = "http://www.webservicex.net/globalweather.asmx";
var oRequest = {"http://www.webserviceX.NET:GetWeather":{CityName:"New York",CountryName:"United States"}};
var cAction = "http://www.webserviceX.NET/GetWeather";
var ver = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,oAuthenticate:oAuthenticator,bEncoded:false,cVersion:ver});

var oAuthenticator ={ UsePlatformAuth: "true"};
var cURL = "http://www.guru4.net/articoli/javascript-soap-client/demo/webservicedemo.asmx";
var oRequest = {"http://www.guru4.net:HelloTo":{name:"leakim971"}};
var cAction = "http://www.guru4.net/HelloTo";
var cVersion = SOAPVersion.version_1_2;
SOAP.wireDump = "true";
var response = Net.SOAP.request({cURL:cURL,oRequest:oRequest,cAction:cAction,oAuthenticate:oAuthenticator,bEncoded:false,cVersion:cVersion});
app.alert(response);
0
leakim971PluritechnicianCommented:
good.
You can remove : SOAP.wireDump = "true";
It's just to debug SOAP messages
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lp84Author Commented:
Ah..thanks a lot for all your help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

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.