Among other things, did you change
public String VlozFotoAuto(AuthData authData, Integer autoPlusId, Byte[] obsah)
throws Exception
and
params.addElement(new Parameter("obsah", java.lang.Byte[].class, obsah, null));
changing Byte[] to byte[] both places?
Note that what you lose is the ability to have an array element that is null: a Byte
can be null, but a byte cannot.
Scott Nichol
Do not send e-mail directly to this e-mail address,
because it is filtered to accept only mail from
specific mail lists.
----- Original Message -----
From: "Pospisil, Pavel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 28, 2004 11:38 AM
Subject: RE: How to send Byte[] as Base64Binary and not Array Type with SOAP 2.3.1
Hallo,
thank You for Your answer.
I have no experience with write my own serializer
so I tried Your solution nr. 1, (change Byte[] to byte[]) but no success.
My client standing generate
.....
<obsah xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/"
xsi:type="ns2:Array" ns2:arrayType="xsd:byte[116]">
<item xsi:type="xsd:byte">65</item>
<item xsi:type="xsd:byte">70</item>
...
I tried:
BeanSerializer beanSer = new BeanSerializer();
m_smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:Autoplus",
"FotoAuto"), FotoAuto.class, beanSer, beanSer);
Base64Serializer b64Ser = new Base64Serializer();
m_smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:Autoplus",
"FotoAuto"), FotoAuto.class, b64Ser, b64Ser);
but the result is the same.
What now ?
Pavel
> -----Původní zpráva-----
> Od: Scott Nichol [SMTP:[EMAIL PROTECTED]
> Odesláno: 27. dubna 2004 19:16
> Komu: [EMAIL PROTECTED]
> Předmět: Re: How to send Byte[] as Base64Binary and not Array Type
> with SOAP 2.3.1
> Důležitost: Malá
>
> You have 2 choices
>
> 1. Change your code to use byte[] instead of Byte[].
>
> 2. Write your own serializer and de-serializer for Byte[] and register it.
> The serializer would probably convert Byte[] to byte[] and delegate to the
> Base64Serializer. The deserializer would do the opposite: delegate to
> Base64Deserializer then convert byte[] to Byte[].
>
> Scott Nichol
>
> Do not send e-mail directly to this e-mail address,
> because it is filtered to accept only mail from
> specific mail lists.
>
> ----- Original Message -----
> From: "Pospisil, Pavel" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 27, 2004 12:08 PM
> Subject: How to send Byte[] as Base64Binary and not Array Type with SOAP
> 2.3.1
>
>
> Hallo,
> i am trying to write SOAP Client with ORACLE JDeveloper and Apache 2.3.1
> from WSDL with some user types.
>
> JDeveloper generated some code for me (service has more methods, this is
> only snippet)
> .....
> /**
> * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton
> Generator.
> * Date Created: Thu Mar 18 18:09:08 CET 2004
> *
> * <pre>
> * <complexType name="FotoAuto">
> * <all>
> * <element name="fotoId" type="xsd:string"/>
> * <element name="url" type="xsd:string"/>
> * <element name="obsah" type="xsd:base64Binary"/>
> * </all>
> * </complexType>
> * </pre>
> */
>
> public class FotoAuto
> {
> private String m_fotoId;
> private String m_url;
> private Byte[] m_obsah;
> public FotoAuto()
> {
> }
>
> public FotoAuto(String fotoId, String url, Byte[] obsah)
> {
> m_fotoId = fotoId;
> m_url = url;
> m_obsah = obsah;
> }
>
> }
>
> import org.apache.soap.transport.http.SOAPHTTPConnection;
> import org.apache.soap.encoding.soapenc.BeanSerializer;
> import org.apache.soap.encoding.soapenc.Base64Serializer;
> import org.apache.soap.encoding.SOAPMappingRegistry;
> import org.apache.soap.util.xml.QName;
> import java.net.*;
> import java.net.URL.*;
> import java.util.Vector;
> import java.util.Properties;
> import org.apache.soap.Constants;
> import org.apache.soap.Fault;
> import org.apache.soap.SOAPException;
> import org.apache.soap.rpc.Call;
> import org.apache.soap.rpc.Parameter;
> import org.apache.soap.rpc.Response;
>
> import FotoAuto;
> import com.sun.net.ssl.*;
> import javax.net.ssl.*;
> import java.security.*;
> import java.security.cert.*;
> import HTTPClient.*;
> import java.io.*;
>
> public class AutoplusServiceStub
> {
> public String endpoint = "http://www.auto-plus.cz/services/index.php";
> // private static OracleSOAPHTTPConnection m_httpConnection = null;
> // private static SOAPHTTPConnection m_httpConnection = null;
> private TrustfulSOAPHTTPConnection m_httpConnection = null;
> private SOAPMappingRegistry m_smr = null;
>
> public AutoplusServiceStub()
> {
>
> System.setProperty("java.protocol.handler.pkgs","HTTPClient");
> Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
>
> m_httpConnection = new TrustfulSOAPHTTPConnection();
> m_smr = new SOAPMappingRegistry();
> m_httpConnection.setProxyHost("127.0.0.1");
> m_httpConnection.setProxyPort(5865);
>
> BeanSerializer beanSer = new BeanSerializer();
> // Base64Serializer b64Ser = new Base64Serializer();
> m_smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:Autoplus",
> "FotoAuto"), FotoAuto.class, beanSer, beanSer);
> // m_smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:Autoplus",
> "FotoAuto"), FotoAuto.class, b64Ser, b64Ser);
> }
>
>
> public String VlozFotoAuto(AuthData authData, Integer autoPlusId, Byte[]
> obsah) throws Exception
> {
> String returnVal = null;
>
> URL endpointURL = new URL(endpoint);
> Call call = new Call();
> call.setSOAPTransport(m_httpConnection);
> call.setTargetObjectURI("urn:Autoplus");
> call.setMethodName("VlozFotoAuto");
> call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
>
> Vector params = new Vector();
> params.addElement(new Parameter("authData",
> gedas.DMS.AutoPlus.AuthData.class, authData, null));
> params.addElement(new Parameter("autoPlusId", java.lang.Integer.class,
> autoPlusId, null));
> params.addElement(new Parameter("obsah", java.lang.Byte[].class,
> obsah,
> null));
> call.setParams(params);
>
> call.setSOAPMappingRegistry(m_smr);
>
> Response response = call.invoke(endpointURL,
> "urn:Autoplus#ws_autoplus#VlozFotoAuto");
>
> if (!response.generatedFault())
> {
> Parameter result = response.getReturnValue();
> returnVal = (String)result.getValue();
> }
> else
> {
> Fault fault = response.getFault();
> throw new SOAPException(fault.getFaultCode(),
> fault.getFaultString());
> }
>
> return returnVal;
> }
> }
>
> So, most of methods are running ok, but when i try use this (VlozFotoAuto)
> my request is generated as:
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <SOAP-ENV:Body>
> <ns1:VlozFotoAuto xmlns:ns1="urn:Autoplus"
> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <authData xsi:type="ns1:AuthData">
> <login xsi:type="xsd:string">login</login>
> <password xsi:type="xsd:string">passw</password>
> </authData>
> <autoPlusId xsi:type="xsd:int">20791</autoPlusId>
> <obsah xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/"
> xsi:type="ns2:Array" ns2:arrayType="xsd:byte[116]">
> <item xsi:type="xsd:byte">65</item>
> <item xsi:type="xsd:byte">70</item>
> <item xsi:type="xsd:byte">81</item>
> .....
> instead of xsi:type="xsd:base64Binary"/>
> Why ????
>
> Server consequently returns:
> <?xml version="1.0" encoding="UTF-8"?>
>
> <SOAP-ENV:Envelope
> xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
> SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
> <SOAP-ENV:Body>
>
> <SOAP-ENV:Fault>
> <faultcode xsi:type="xsd:QName">SOAP-ENV:Client</faultcode>
> <faultstring xsi:type="xsd:string">soap request contained mismatching
> parameters of name obsah had type [array], which did not match signature's
> type: [base64Binary], matched? 1</faultstring>
> <faultactor xsi:type="xsd:anyURI"></faultactor>
> <detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault>
> </SOAP-ENV:Body>
> </SOAP-ENV:Envelope>
>
> And client with:
> [SOAPException: faultCode=SOAP-ENV:Client; msg=A
> 'http://schemas.xmlsoap.org/soap/envelope/:Fault' element must
> contain a: 'faultcode' element.;
> targetException=java.lang.IllegalArgumentException: A
> 'http://schemas.xmlsoap.org/soap/envelope/:Fault' element must contain a:
> 'faultcode' element.] at org.apache.soap.rpc.Call.invoke(Call.java:294)
>
> I am using SOAP 2.3.1
>
> Where am I wrong ???
>
> Thanks
> Pavel
>