Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

web service problem

  Asked By: Nicole    Date: Jul 19    Category: Java    Views: 1357
  

i am trying to call a webservice deployed on weblogic. i have a java client for that.
my problem is , when i try to call the web service over ssl, i have this error:

Error deserializing arguments.
Unrecognized element userName - expected partnerId@http://www.openuri.org/
Caused by:
com.bea.xml.marshal.XmlEncodingException:

userName and partnerId are two of the parameters i send to the service.

when i invoke the web service over http, it works fine. below are my two different soap messages that were sent to web service.one of them works fine, the other fails with the previous exception. "getPrmCdr " is the method i invoke.

working.xml:


<?
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">
<soapenv:Body>
<getPrmCdr xmlns="http://www.openuri.org/">
<userName>dummy.partner1</userName>
<partnerId>10101010</partnerId>
<serviceNo>1111</serviceNo>
<date>20060212</date>
</getPrmCdr>
</soapenv:Body>
</
soapenv:Envelope>

fails.xml

<?
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">
<env:Body
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<m:getPrmCdr xmlns:m="http://www.openuri.org/">
<userName xsi:type="xsd:string">dummy.partner1</userName>
<partnerId xsi:type="xsd:int">10101010</partnerId>
<serviceNo xsi:type="xsd:string">1111</serviceNo>
<date xsi:type="xsd:string">20060212</date>
</m:getPrmCdr>
</env:Body>
</
env:Envelope>

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Erika Evans     Answered On: Jul 19

Your class should implement java.io.Serializable and contains these parameter and methods :


private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(User.class, true);

static {
typeDesc.setXmlType(new javax.xml.namespace.QName("Url of User class", "User"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("userName");
elemField.setXmlName(new javax.xml.namespace.QName("", "userName"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("partnerId");
elemField.setXmlName(new javax.xml.namespace.QName("", "partnerId"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("serviceNo");
elemField.setXmlName(new javax.xml.namespace.QName("", "serviceNo"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("date");
elemField.setXmlName(new javax.xml.namespace.QName("", "date"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}

/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}

/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}

/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}

 
Answer #2    Answered By: Jermaine Powell     Answered On: Jul 19

I think you should use Serializable and Deserializable to send  and recieve Xml to Object and Object to Xml for example you can using hashTable to
put your environment in it
for example in java  5 and EJB3.0 :


Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099"); // remote machine IP

try {
InitialContext context = new InitialContext(environment);
RemoteAgentFacade rbi = (RemoteAgentFacade) context.lookup(RemoteAgentFacade.class.getName());
if(rbi.canLogin("Hatami")) {
System.out.println("Ok");
}

and you should have specify LoginModule for your connection to server that able to across SSL and using JAAS for LoginModule.

 
Didn't find what you were looking for? Find more on web service problem Or get search suggestion and latest updates.




Tagged: