Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Package oracle.spatial does not exist in NetBeans

744977Jul 20 2010 — edited Jul 21 2010
Hi to all,

I have installed Oracle 11g R2. I have installed Netbeans 6.8. All on Red Hat Enterprise 5.
I'm doing a project in Netbeans that use package oracle.spatial. So I have imported this package so:

import oracle.spatial.*;

But netbeans says that this package doesn't exist.


Listener is active.
Database is up.
Netbeans is already connected to Oracle with driver oracle.jdbc.OracleDriver.
I have set the classpath in the project: I have added the jar file ojdbc6.jar in the libraries of the project.

What do you think about this problem?


thank you for help in advance.
This post has been answered by ZahKar on Jul 21 2010
Jump to Answer

Comments

843833
Hi!
I have the same problem, so if you find out, please post the solution.

Thnx in advance, tadey
843833
hi,

For sending attachments over the wire you will have to use SOAP. SOAP allows you to add any non-XML content as so called attachments to your SOAP message. The attachment mechanism works in both ways: client->server/ server->client.

The most obvious way would be to create a SOAPMessage, put the response String in the SOAPBody and later add an AttachmentPart to the SOAPMessage. Take a look at the SAAJ stuff that came with your axis package. The SAAJ API is quite informative!

Some more or less helpfull examples can be found in the axis samples directory. I've also spent a lot of time with them. In most cases you won't find exactly what you need, but they are better than nothing ;)

Good luck.
Cheerz ryner.
843833
hi,

Once again ;)
After a few trys'n'errors here a piece of code that would send a simple attachment back to where it came from. It simply returns the given String parameter 's' as text/plain attachment:
package wsclient;

import javax.xml.soap.AttachmentPart;
import org.apache.axis.MessageContext;

import org.apache.axis.Message;
import org.apache.axis.MessageContext;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author 
 * @version 1.0
 */
public class SimpleTexter {
    public SimpleTexter() {
    }
    public void getSimpleText(String s) throws Exception
    {
        // the message context stores all the request/response specific stuff
        MessageContext msgContext= MessageContext.getCurrentContext();
        Message response = msgContext.getResponseMessage();
        
        // create an attachment and set its mime type
        AttachmentPart a = response.createAttachmentPart();
        a.setContent(s, "text/plain");
        response.addAttachmentPart(a);
        response.saveChanges();

        // when we leave the method, axis will do all the rest for you
    }
}
a request looking similar to something like:
POST /axis/services/SimpleTexter HTTP/1.0

Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.2RC2
Host: 127.0.0.1:999
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: ""
Content-Length: 364

<?xml version="1.0" encoding="UTF-8"?>
   <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:a0="http://wsclient"> 
      <soapenv:Body>  
         <a0:getSimpleText>   
            <a0:s>simpleText</a0:s>  
         </a0:getSimpleText> 
      </soapenv:Body>
   </soapenv:Envelope>
would return something like:
HTTP/1.1 200 OK

Content-Type: multipart/related; type="text/xml"; start="<FB0BA99519172A12CB27573B2292C73F>"; 	boundary="----=_Part_0_24522695.1118845671825"Date: Wed, 15 Jun 2005 14:27:52 GMTServer: Apache-Coyote/1.1Connection: close------=_Part_0_24522695.1118845671825Content-Type: text/xml; charset=UTF-8Content-Transfer-Encoding: binaryContent-Id: 
   <FB0BA99519172A12CB27573B2292C73F>
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
         <soapenv:Body/>
      </soapenv:Envelope>

------=_Part_0_24522695.1118845671825

Content-Type: text/plain
Content-Transfer-Encoding: binary
Content-Id: 
      <9C2BE77871B9E5805BE6E46F43ABA33E>simpleText

------=_Part_0_24522695.1118845671825--
I hope that helps!

Cheerz, r.
843833
Hi!

Thanks, It really helps, but i still have a problem,
I tried your example and when I call the web service, I get after:
AttachmentPart a = response.createAttachmentPart();
NullPointerExeption, and I do not know what is wrong.

Can you please help me again.
Thnx in advance, tadey

Here is my code
package server;

import javax.xml.soap.AttachmentPart;
import org.apache.axis.Message;
import org.apache.axis.MessageContext;

public class wservice {
	
	public void getSimpleText(String s) throws Exception
    {
        // the message context stores all the request/response specific stuff
        MessageContext msgContext= MessageContext.getCurrentContext();
        Message response = msgContext.getResponseMessage();
        
        // create an attachment and set its mime type
        AttachmentPart a = response.createAttachmentPart();
        a.setContent(s, "text/plain");
        response.addAttachmentPart(a);
        response.saveChanges();
// 
        // when we leave the method, axis will do all the rest for you
    }

}
843833
hi,
I tried your example and when I call the web service,
I get after:
AttachmentPart a =
response.createAttachmentPart();

NullPointerExeption, and I do not know what is
s wrong.
jo, the example i showed above is really a quick hack! as you can see, the method 'getSimpleText' has return type 'void' indicating that this web service operation is a one-way-operation only. so, actually no response is expected. And due to this, i guess that the corresponsing MessageContext will not store a response message.I think this would explain your NullPointerException.

it worked over here, because i deployed it as wrapped rpc style service and axis created a 'dummy' response type in the wsdl (porttype/operation/output). Here is my deployment descriptor.
<!-- -->
<deployment name="testEnv_deploy"
            xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <service name="SimpleTexter" provider="java:RPC" style="wrapped">
    <parameter name="className" value="wsclient.SimpleTexter"/>
    <parameter name="allowedMethods" value="*"/>
  </service>
</deployment>
axis will create the following wsdl (excuse bad formatting):
<wsdl:definitions targetNamespace="http://localhost:8080/axis/services/SimpleTexter">
	<!--
WSDL created by Apache Axis version: 1.2RC2
Built on Nov 16, 2004 (12:19:44 EST)
-->
	<wsdl:types>
	<schema elementFormDefault="qualified" targetNamespace="http://wsclient">
	<element name="getSimpleText">
	<complexType>
	<sequence>
        <element name="tns1:s" type="xsd:string"/>
        </sequence>
        </complexType>
        </element>
	<element name="getSimpleTextResponse">
        <complexType/>
        </element>
</schema>
</wsdl:types>
	<wsdl:message name="getSimpleTextResponse">
<wsdl:part element="tns1:getSimpleTextResponse" name="parameters"/>
</wsdl:message>
	<wsdl:message name="getSimpleTextRequest">
<wsdl:part element="tns1:getSimpleText" name="parameters"/>
</wsdl:message>
	<wsdl:portType name="SimpleTexter">
	<wsdl:operation name="getSimpleText">
<wsdl:input message="impl:getSimpleTextRequest" name="getSimpleTextRequest"/>
<wsdl:output message="impl:getSimpleTextResponse" name="getSimpleTextResponse"/>
</wsdl:operation>
</wsdl:portType>
	<wsdl:binding name="SimpleTexterSoapBinding" type="impl:SimpleTexter">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
	<wsdl:operation name="getSimpleText">
<wsdlsoap:operation soapAction=""/>
	<wsdl:input name="getSimpleTextRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
	<wsdl:output name="getSimpleTextResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
	<wsdl:service name="SimpleTexterService">
	<wsdl:port binding="impl:SimpleTexterSoapBinding" name="SimpleTexter">
<wsdlsoap:address location="http://localhost:8080/axis/services/SimpleTexter"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
a somehow better solution would be to make the whole thing a message style service (take a look at the axis user guide for more info). in this case, your body is not bound to a single 'string' parameter, you can pass what ever you want as long as it is embodied in an element with name 'getSimpleText'. (i use a quite similar piece of code to simply echo requests)
package wsclient;

// imports

public class SimpleTexter
{
//constructor ...

// this is a valid signature for a message style operation
// in any case, that should make sure, you have a request/response operation.
// This signature is useless if you have to handle attachments. but good enough to
// process simple requests/responses without attachments
public SOAPEnvelope getSimpleText(SOAPEnvelope req, SOAPEnvelope resp)
{
        // the message context stores all the request/response specific stuff
        MessageContext msgContext= MessageContext.getCurrentContext();
        // to add an attachment, you need the response Message
        // resp is useless, because you cannot add attachtments to the envelope
        Message response = msgContext.getResponseMessage();
        
        // do something with the request, if you want....
        // you can either take 'req' or call msgContext.getRequestMessage().
        // use the latter call, if you expect attachments to be sent by the client,
        // because you can't acces them through the envelope :-(

        // ...

        // create an attachment
        AttachmentPart a = response.createAttachmentPart();
        // place the content. if you want to pass an image, you will need a
        // javax.activation.DataHandler. 
        // then you don't have to take care about mime types
        a.setContent(/*your attachment datahandler*/);
        response.addAttachmentPart(a);
        response.saveChanges();

        return response.getEnvelope();
}
}
i didn't test this piece of code. i hope it works in a somehow similar way ;)
don't forget to deploy this class as message style service:
<deployment name="testEnv_deploy"
            xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <service name="SimpleTexter" provider="java:MSG">
    <parameter name="className" value="wsclient.SimpleTexter"/>
    <parameter name="allowedMethods" value="*"/>
  </service>
</deployment>
i hope that helps you out again! good luck!
cheerz, r.
843833
Hi!
Thnx in your help.
I tested your advice , but I have still same problem, I use Eclipse 3.1.0 and Apache Tomcat 5.0., and j2sdk 1.4.2_07
I have tested even other examples, like:

I tried to make SOAP message with soapfactory in client, and then I caled:

AttachmentPart a = response.createAttachmentPart();

and also get null pointer exeption.

This is client-side code:
public static void main(String args[]) throws MalformedURLException, SOAPException {
	MessageFactory factory = MessageFactory.newInstance();
		SOAPMessage msg = factory.createMessage();
		SOAPConnectionFactory connectionFactory=   SOAPConnectionFactory.newInstance();
		SOAPConnection con = connectionFactory.createConnection();

AttachmentPart attachment = msg.createAttachmentPart(); // here i get NullPointException
	String stringContent = "Update address for Sunny Skies " + 
	  "Inc., to 10 Upbeat Street, Pleasant Grove, CA 95439";

		attachment.setContent(stringContent, "text/plain");
		attachment.setContentId("update_address");

		msg.addAttachmentPart(attachment); 
		
		msg.saveChanges();

		 create the endpoint and send the message
		 URL endpoint = new URL("http://localhost:9090/RKO/services/zmogljivost");
		 con.call.setOperationName(new QName(endpoint, "sayHelloTo"));
		 SOAPMessage response = con.call(message, endpoint);
}
I do not know what to do?
Can you help me again?Plese!
Is something wrong with my Eclipse, apache, or j2sdk?

Thnx in advance

tadey
843833
hi,
I tried to make SOAP message with soapfactory in
client, and then I caled:

AttachmentPart a = response.createAttachmentPart();
Hmm, I've also read the other thread, where you wrote about a NullPointerException. It seems that your factory always returns null instead of a valid SOAPMessage instance. Maybe something is wrong with your saaj or axis setup. Did you include all required packages in your project path... eg. the axis package instead of the saaj package only?

Try to take a look on the implementation of the javax.xml.soap.MessageFactory in the axis package. There you should find some path information, from where the factory actually takes the sources. I guess that the factory can't find an implementation and therefore returns null instead... !?

I wish you all the best :)
Cheerz, r.
843833
Hi,

I had exactly the same problem. I kept getting a NullPointerException when using the Factory to create an AttachementPart.

I was able to resolve the problem :-) You will need to make sure that you have added the mail.jar to your classpath. The createAttachmentPart uses javax.mail.* package to create the AttachmentPart

http://java.sun.com/products/javamail/

Good luck with it.
A+
843833
Hi,

I have created a service, which takes files uploaded from client and attaches files again, so that client can download it.

My method signature :
public void attachmentUtility()

I am able to access the files which are uploaded by client.

But getting java.io.IOException clientabortexception, socket exception at server side. I think this is because of my service method having signature void.

If so what should be the my method signature to send SOAPMessage to client?

Java2WSDL tool didn't created wsdl:types in my WSDL types.

Please send sample code, how can achive this?

Below is my service method,

public void attachmentUtility()
{
System.out.println("FileAttachmentAxisSAAJ::attachmentUtility");

MessageContext messageContext = null;

messageContext = MessageContext.getCurrentContext();

if( messageContext!=null )
{
System.out.println("Message context created.....");

Message requestMessage = messageContext.getRequestMessage();

if( requestMessage!=null )
{
System.out.println("Request has come.....service received it!");
System.out.println("Number of attachments sent by client: "+requestMessage.countAttachments());
}


Message responseMessage = messageContext.getResponseMessage();

if( responseMessage!=null )
{
System.out.println("Response message is not null in server****");

AttachmentPart attachPart = null;

DataHandler dh = new DataHandler( new FileDataSource("C:\\DSCN0705.JPG"));

attachPart = responseMessage.createAttachmentPart(dh);

attachPart.setContentId("attachment-1");

responseMessage.addAttachmentPart(attachPart);

System.out.println("***Attachemtn is successfully attached to response message***");

}
else
{
System.out.println("Response message is NULL in server****");
}

}
}


--------------------
My WSDL file

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="some:com.lmr.ems.tcs.services.attach" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="some:com.lmr.ems.tcs.services.attach" xmlns:intf="some:com.lmr.ems.tcs.services.attach" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.2.1
Built on Jun 14, 2005 (09:15:57 EDT)-->

<wsdl:message name="attachmentUtilityResponse">

</wsdl:message>

<wsdl:message name="attachmentUtilityRequest">

</wsdl:message>

<wsdl:portType name="FileAttachmentAxisSAAJ">

<wsdl:operation name="attachmentUtility">

<wsdl:input message="impl:attachmentUtilityRequest" name="attachmentUtilityRequest"/>

<wsdl:output message="impl:attachmentUtilityResponse" name="attachmentUtilityResponse"/>

</wsdl:operation>

</wsdl:portType>

<wsdl:binding name="FilwUploadDownload14SoapBinding" type="impl:FileAttachmentAxisSAAJ">

<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="attachmentUtility">

<wsdlsoap:operation soapAction=""/>

<wsdl:input name="attachmentUtilityRequest">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="some:com.lmr.ems.tcs.services.attach" use="encoded"/>

</wsdl:input>

<wsdl:output name="attachmentUtilityResponse">

<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="some:com.lmr.ems.tcs.services.attach" use="encoded"/>

</wsdl:output>

</wsdl:operation>

</wsdl:binding>

<wsdl:service name="FileAttachmentAxisSAAJService">

<wsdl:port binding="impl:FilwUploadDownload14SoapBinding" name="FilwUploadDownload14">

<wsdlsoap:address location="http://venkats:8080/venkat/services/FilwUploadDownload14"/>

</wsdl:port>

</wsdl:service>

</wsdl:definitions>


Regards,
Venkat S
1 - 9
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 18 2010
Added on Jul 20 2010
9 comments
2,547 views