• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Need Help in passing a string as a attachment  RSS feed

 
Ranch Hand
Posts: 598
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to pass a string as a attachment, but when I examine what is being sent it looks as if the string is being passed in the Body.

According to weblogic :
Certain Java data types, if used as parameters or return values of a method that implements a Web Service operation, are automatically transported as SOAP Attachments (rather than elements in the SOAP body) when going over the wire.

As I understand it this means passing a parameter as a datahandler.

Here is my code snippet

String attachement = attach.getAttachments().toString();
StringDataSource sds = new StringDataSource(attachement,"String","Attachment");

DataHandler dh = new DataHandler(sds);
Results res = new Results();

//The remote soap call.
port.scanForViruses(dh);

I have created a DataHandler and am passing it as a parameter, as laid down in weblogic.

I have set up a sniffer, but not sure what I should be looking for to say it has been passed as a Attachement:
Here is the sniffer output:

------ 10.101.193.171:11001->localhost:3669 ------
HTTP/1.1 200 OK
Date: Thu, 08 Jun 2006 09:53:52 GMT
Content-Length: 2338
Content-Type: text/xml
Connection: Keep-Alive

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:tns="http://www.inlandrevenue.gov.uk/schemas/AntiVirusSoapService"
xmlns:wsr="http://www.openuri.org/2002/10/soap/reliability/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap12enc="http://www.w3.org/2003/05/soap-encoding"
xmlns:conv="http://www.openuri.org/2002/04/wsdl/conversation/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="http://www.inlandrevenue.gov.uk/schemas/AntiVirusSoapService">
<message name="scanForViruses">
<part xmlns artns="http://www.w3.org/2001/XMLSchema"
type="partns:anyType"
name="dataHandler">
</part>
</message>
<message name="scanForVirusesResponse">
<part xmlns artns="http://www.w3.org/2001/XMLSchema"
type="partns:string"
name="result">
</part>
</message>
<portType name="AntiVirusProcessPort">
<operation name="scanForViruses">
<input message="tns:scanForViruses">
</input>
<output message="tns:scanForVirusesResponse">
</output>
</operation>
</portType>
<binding type="tns:AntiVirusProcessPort"
name="AntiVirusProcessPort">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http">
</soap:binding>
<operation name="scanForViruses">
<soap peration style="rpc"
soapAction="">
</soap peration>
<input>
<soap:body namespace="http://www.inlandrevenue.gov.uk/schemas/AntiVirusSoapService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
use="encoded">
</soap:body>
</input>
<output>
<soap:body namespace="http://www.inlandrevenue.gov.uk/schemas/AntiVirusSoapService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
use="encoded">
</soap:body>
</output>
</operation>
</binding>
<service name="AntiVirusProcess">
<port name="AntiVirusProcessPort"
binding="tns:AntiVirusProcessPort">
<soap:address location="http://localhost:11001/AntiVirus/AntiVirusProcess">
</soap:address>
</port>
</service>
</definitions>
------ localhost:3669->10.101.193.171:11001 ------
POST /AntiVirus/AntiVirusProcess HTTP/1.0
Content-Type: multipart/related;type="text/xml";boundary="----=_Part_3_2425209.1149760420359";start=__WLS__1149760420359__SOAP__; charset=utf-8
SOAPAction: ""
User-Agent: Java1.4.2_08
Host: localhost:11001
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: Keep-Alive
Content-Length: 94199


------ localhost:3669->10.101.193.171:11001 ------

------=_Part_3_2425209.1149760420359
Content-Type: text/xml; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-ID: __WLS__1149760420359__SOAP__

<?xml version="1.0" encoding="utf-8" standalone="yes"?><env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
------=_Part_3_2425209.1149760420359
Content-Id: <dataHandler>


Hello World
JUVPRgo=
[09090909]
------=_Part_3_2425209.1149760420359--

------ 10.101.193.171:11001->localhost:3669 ------
HTTP/1.1 200 OK
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!