Re: AW: AW: Complex JavaType in a Request to Axis

[email protected] Wed, 9 Jul 2003 16:53:11 +0200
Newsgroups gmane.comp.java.enhydra.ksoap
Message-ID <[email protected]>
I'm happy it helped you :-)

Well for HTTPS, you don't need to do anything with kSoap as it uses a 
separate transport layer.
For J2SE, you can just use 'HttpTransportSE', which itself uses a standard 
URLConnection.

If your kSoap client is running on top of J2SE, then you can just use the 
JSSE extension.

As of J2SE 1.4, JSSE is a standard component, so you can connect to an 
HTTPS
webservice by just using an 'https://' url.

For J2SE 1.3, you need to install JSSE, and then normally use 'https://' 
urls.

For J2ME ... I don't know, I never used it :-)

On the Axis side, check the Axis documentation, there must be something 
that explain how to setup SSL.

FYI, I use kSoap 1.2 on my server and my clients, over HTTPS with mutual 
authentication (all running on top of J2SE 1.4.1).
We even used kSoap 1.2 with HTTP digest authentication...

Regards,

----------------------------------------------------------------------------
Sebastien Petrucci
Java Technology Consultant - Altran Europe
Philips Remote Control Systems
Interleuvenlaan 74-76, B-3001 Leuven (Belgium)
M +32(0)497502521    T  +32(0)16394 598
----------------------------------------------------------------------------









[email protected]
2003-07-09 16:40

 
        To:     Sebastien Petrucci/LEU/COMP/PHILIPS@EMEA1
        cc: 
        Subject:        AW: AW: Ksoap:  Complex JavaType in a Request to Axis
        Classification: 



Thanx, thanx, thanx.
It all works very well.
But I have another new problem. What can I do to use the secure-protocol 
SSL? 
I want to use a HTTPS-url with kSOAP...

I hope it's ok that I "bomb" you with eMail... ;-)

Greetz,
Frank

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]]
Gesendet: Dienstag, 8. Juli 2003 17:18
An: Frank Löber
Betreff: Re: AW: Ksoap: Complex JavaType in a Request to Axis


In fact, if you look into the WSDL generated by Axis, you should find the 
XML-Schema definition
of the "User" type.
This type consists of a namespace and a type name. So you just have to 
replace "urn:mycompany.com"
with the namespace and "User" with the type name.

KvmSerializable (defined in kSoap 1.x, don't know for kSoap 2.x) is an 
interface.
To use it, just create a User object and make it implement the 
KvmSerializable interface.
I cannot tell you much more on this topic as I never used it.

Here is a marshaller example (for kSoap 1.2). Note that I just derived 
this code from something else and 
I did not try to compile it. It might contain errors but the idea is 
there. By creating a marshaller, you can
control how an object is (de)serialized using KXML (so at the XML level).
You can also have a look to the provided marshallers in the kSoap sources. 

Do not forget to register
a marshaller before you use it.

public class MarshalEpgProperties implements Marshal
{
    private static ElementType ELEMENT_TYPE_STRING = new 
ElementType(ElementType.STRING_CLASS);

    private static final String NAMESPACE = "urn:mycompany.com";
    private static final String XML_TYPE = "user";
    private static final Class JAVA_CLASS = com.company.User.class;

    public Object readInstance(SoapParser parser, String namespace, String 

name, ElementType expected) throws IOException
    {
        com.company.User instance = new com.company.User();
        AbstractXmlParser xmlParser = parser.parser;

        // advance <xxx:User>
        xmlParser.read(Xml.START_TAG, null, "name");
        instance.setName( xmlParser.readText() );
        xmlParser.skip();

        xmlParser.read(Xml.START_TAG, null, "password");
        instance.setPassword( xmlParser.readText() );
        xmlParser.skip();

        xmlParser.read(Xml.START_TAG, null, "email");
        instance.setEmail( xmlParser.readText() );
        xmlParser.skip();

        // advance </xxx:User>
        xmlParser.read();

        return instance;
    }

    public void writeInstance(SoapWriter writer, Object instance) throws 
IOException
    {
        com.company.User user = (com.company.User)instance;

        writer.writer.startTag("name");
        writer.writer.write(user.getName());
        writer.writer.endTag();

        writer.writer.startTag("password");
        writer.writer.write(user.getPassword());
        writer.writer.endTag();

        writer.writer.startTag("email");
        writer.writer.write(user.getEmail());
        writer.writer.endTag();
    }

    public void register(ClassMap classMap)
    {
        classMap.addMapping(NAMESPACE, XML_TYPE, JAVA_CLASS, this);
    }

}

----------------------------------------------------------------------------
Sebastien Petrucci
Java Technology Consultant - Altran Europe
Philips Remote Control Systems
Interleuvenlaan 74-76, B-3001 Leuven (Belgium)
M +32(0)497502521    T  +32(0)16394 598
----------------------------------------------------------------------------









[email protected]
2003-07-08 16:57

 
        To:     Sebastien Petrucci/LEU/COMP/PHILIPS@EMEA1
        cc: 
        Subject:        AW: Ksoap:  Complex JavaType in a Request to Axis
        Classification: 



Thanx for the quick answer...
But I do not understand what I have to inset for the first parameter
SoapOject user = new SoapObject("urn:mycompamy.com", "User");
I've tried it with the namespace of my web service 
(complexService:complex) and got the fault: Prefix for namespace 
complexService:complex undefiened!
Can you please help me a second time...

Have you sample-code fpr the marshaller or KvmSerializable object?

Greetz,
Frank


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]]
Gesendet: Dienstag, 8. Juli 2003 16:23
An: [email protected]
Betreff: Re: Ksoap: Complex JavaType in a Request to Axis


You can create your own marshaller or a KvmSerializable object.

Another option that I tend to use more frequently is to "encode yourself"
your objects into SoapObjects. 
Ex :

...

// SoapObject user = new 
SoapObject("namespace-of-your-xml-type","name-of-your-xml-type")

SoapOject user = new SoapObject("urn:mycompamy.com", "User");
user.addProperty("name", aUser.getName());
user.addProperty("password", aUser.getPassword());
user.addProperty("email", aUser.getEmail());

SoapObject request = new SoapObject("service-namespace", "service-name");
request.addProperty("user", user);

...

Hope it helps,

----------------------------------------------------------------------------
Sebastien Petrucci
Java Technology Consultant - Altran Europe
Philips Remote Control Systems
Interleuvenlaan 74-76, B-3001 Leuven (Belgium)
M +32(0)497502521    T  +32(0)16394 598
----------------------------------------------------------------------------









<[email protected]>
Sent by: 
[email protected]
2003-07-08 15:56
Please respond to ksoap

 
        To:     <[email protected]>
        cc:     (bcc: Sebastien Petrucci/LEU/COMP/PHILIPS)
        Subject:        Ksoap:  Complex JavaType in a Request to Axis
        Classification: 



Hi,
i'm trying to send a complex JavaType to an Axis Web Service. But I have 
no idea how this works...
For example the complex javaType "User" with the String-elements "name", 
"password", "email".
Can anybody give me an example?
Thanx a lot!

------------------------------------------------------------------------------------
Frank Löber
Diplomand
mailto: [email protected]

Avinci - The Know-How Company
Insterburger Straße 7
60487 Frankfurt am Main
http://www.avinci.biz
------------------------------------------------------------------------------------


_______________________________________________
Ksoap mailing list
[email protected]
http://www.enhydra.org/mailman/listinfo.cgi/ksoap




_______________________________________________
Ksoap mailing list
[email protected]
http://www.enhydra.org/mailman/listinfo.cgi/ksoap