Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

SOAP Header Authentication!!!

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I am trying to access webservices using java client. I am getting following error:

Fault Code = soap:Server

Fault String = Server was unable to process request. --> Authentication failed. Subscription ID is empty


The service provider providing clinet in .NET ,and our requirement is to use the same service( to find the distance betweent two zip code) in Java.

I have to set sessionID in the header , so the webservice authenticate me in order to use this service.

Please share any sample code, that is doing similar functionality, or kind of help to resolve this problem.


any help in this regard would be highly appreciated.


http://www.codebump.com/services/ZipCodeLookup.asmx?op=GetDistanceBetweenZipCodes
http://www.codebump.com/services/ZipCodeLookup.asmx?WSDL



********************** SOAP REQUEST ****************************************
POST /services/ZipCodeLookup.asmx HTTP/1.1
Host: www.codebump.com
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://skats.net/services/GetDistanceBetweenZipCodes";

<?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:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:tns="http://skats.net/services/"; xmlns:types="http://skats.net/services/encodedTypes"; xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">;
<soap:Header>
<tns:AuthenticationHeader>
<SessionID xsi:type="xsd:string">string</SessionID>
</tns:AuthenticationHeader>
</soap:Header>

<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">;
<tns:GetDistanceBetweenZipCodes>
<zip1 xsi:type="xsd:string">string</zip1>
<zip2 xsi:type="xsd:string">string</zip2>
</tns:GetDistanceBetweenZipCodes>
</soap:Body>
</soap:Envelope>

****************************************************************************************

********************** SOAP Response ****************************************
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?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:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:tns="http://skats.net/services/"; xmlns:types="http://skats.net/services/encodedTypes"; xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">;
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">;
<tns:GetDistanceBetweenZipCodesResponse>
<GetDistanceBetweenZipCodesResult xsi:type="xsd:float">float</GetDistanceBetweenZipCodesResult>
</tns:GetDistanceBetweenZipCodesResponse>
</soap:Body>
</soap:Envelope>
****************************************************************************************


Thanks,

KS
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the explanation on this page?


NOTE: This service requires a subscription.
You can register online using Subscriptions interface. There're several types of subscriptions available including a free subscription so you can continue using the web service without paying. When you subscribe you will be issued a subscriber ID that uniquely identify you. You must submit that ID with every request by setting AuthenticationHeader SOAP header. Consult WSDL for more information.

 
K Saleem
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I have the subscription id and able to access the service using .NET client and a web interface.

KS
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh. Of course. Sorry...

You could use a JAX-RPC handler to add the necessary SOAP Header elements. Here's a sketch:

(no guarantees -- I haven't even compiled it)
 
K Saleem
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

Here is the code we are using to call the service and geting the following error

Generated fault:

Fault Code = soap:Server

Fault String = Server was unable to process request. --> Authentication failed. Subscription ID is empty

Regards,
KS

 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you compare the outgoing SOAP request from the .NET client and the Java client?
 
K Saleem
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
request is same, but we have no tool to compare or get the request format.
from either client..
but the proper format of the request as follows

Here the request format is defined.
http://www.codebump.com/services/ZipCodeLookup.asmx?op=GetDistanceBetweenZipCodes

 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure you can. You just need to start a proxy like Grinder's TCP Sniffer on your client machine and change the .NET client and Java client to use "http://localhost:xxxx/foo" instead of "http://codebump.com/services/zipcodelookup.asmx" where xxxx is the port number you configured your proxy to listen.

You'll be able to see exactly what your client is sending over the TCP connection and compare the requests sent by the different clients.
[ August 04, 2004: Message edited by: Lasse Koskela ]
 
Their achilles heel is the noogie! Give them noogies tiny ad!
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic