• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SOAP with attachments service & client example

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can anyone provide me with a small sample of a soap service & soap client with attachments using saaj. I have been googling for over two weeks now and i couldn't find even a single example for soap service. Please help as am running out of time.


Thanks in advance !!!
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Axis2 comes with a SwA example; Metro probably does, too. The WebServicesFaq links to an article about it that has code.
 
revi akula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lester,
Thanks for your reply...But am new to webservice and i dont understand the concept of artifact generation....am used to eclipse IDE.

Sorry am actually confused how to write a saaj service...i understand the client concept will call the service using :

SOAPMessage smg = conn.call(msg,endpoint);

But how to write a service which accepts the SOAP Message. When i write a service like this...

public SOAPMessage respMsg(SOAP Message){
//code to extract SOAP MEssage using MessageContext
}


I get an exception during the generation of WSDL using eclipse wizard(bottom up) as below :

The service class "com.service.webservice.ServiceServlet" does not comply to one or more requirements of the JAX-RPC 1.1 specification, and may not deploy or function correctly.

My IDE is eclipse and apache tomcat is the server....

Please Help !!!
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) I advise to not use an IDE at first, or you'll not learn some important points about implementing WS.

2) i advise to get an existing example code running before trying to create one of your own, just so you know what's involved.

3) Be aware that JAX-RPC is a different API than SAAJ (it's also obsolete, so I advise not to spend time on it).
 
revi akula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks lester for your timely responses and advice. Will definitely do that. But to save myself from the current urgent requirement, could you please let me know if am heading in the correct direction i.e., by writing something like this on the service side:


public SOAPMessage respAttch(SOAPMessage smgRequest){
//MessageContext
}


And how do i resolve the error i get while generating the WSDL ?

The service class "com.service.webservice.ServiceApp" does not comply to one or more requirements of the JAX-RPC 1.1 specification, and may not deploy or function correctly.

Or can you give some code snippet with method signature
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again:

Lester Burnham wrote:2) i advise to get an existing example code running before trying to create one of your own, just so you know what's involved.

3) Be aware that JAX-RPC is a different API than SAAJ (it's also obsolete, so I advise not to spend time on it).

 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I do not have a complete SAAJ example in stock, but section 5.7 in my SCDJWS 5 study notes will provide several code examples showing how to use SAAJ to create SOAP messages with and without attachments. Download the PDF document here: http://www.slideshare.net/krizsan/scdjws-5-study-notes-3085287
Best wishes!
 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ravi,
I agree with Lester that it's important to get to know the basics of web services and work on simple example code(SAAJ) to work on one of the complex areas of web services "SwA".

Here is a link to sample code. You need to be really patient to go through the tutorial to understand .

By the way, what is your purpose of using SAAJ? Are you in need of sending/ receiving SOAP attachments or just plain SOAP message using SAAJ?

3) Be aware that JAX-RPC is a different API than SAAJ (it's also obsolete, so I advise not to spend time on it).


Well, it's not completely true unless oracle has made usage of J2EE1.4 and prior versions absolete. There are still companies working on J2EE1.3 which still use JAX-RPC1.1.
 
revi akula
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ivan & Naren,

Thanks for your reply ! But since am very new to webservices, am unable to sink any of these bigger topics.

@Ivan : I've d/w the pdf and have gone thro the section u've mentioned. Its pretty good stuff. But as i said, am new so looking out for end to end implementation of some small client & Service example with SAAJ on top of which i can build my service.

@Naren: I've gone thro' the tutorial(not completely though),but again it talks in very detailed level which i cant understand so quickly. And yes my requirement is to send docs from a SOAP client to a Web Service which would do some processing and again give back the output doc to the client.


So, please incase if you have some small client and most importantly the "web service" which would accept the attachments(as i get only client examples but not the service), i will be grateful to you people !!! Thanks in advance.
 
Naren Chivukula
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ravi,

please incase if you have some small client and most importantly the "web service" which would accept the attachments


"Soap with Attachments"(SwA) is one of the niche subjects within Web Services and I understand your problem that you couldn't find useful examples in your case. This is because not many people use this API. You must note that depending on the type of attachment (for mime type extensions refer here), the code changes considerably if not completely. I don't know what file extension types you are interested in. But, whatever it is SwA is normally used along with JAX-RPC or JAX-WS in the latest web services where service provider WSDL should describe attachment mime parts in the soap binding element and correspondingly service provider code should handle attachments differently based on their mime types.
For example if an attachment of pdf (I picked pdf as you mentioned "docs") is expected, then
Partial WSDL:


Web Service end point interface




Sample client (partial code)



Web Service end point implementation (partial code)


There is a topic on this at the end of RMH book. Though, it has not provided any complete example, understanding the theory would be sufficient for anyone to write their own code.
reply
    Bookmark Topic Watch Topic
  • New Topic