I
Ike
I am directly taking from the HelloClient example of DII in JAX_RPC tutorial
from Sun, and altering the values for the webservice
DOTSGeoPhone:GetPhoneInfo described at
http://ws2.serviceobjects.net/gp/GeoPhone.asmx?op=GetPhoneInfo
I am getting an "unexpected encoding style," error
when it gets to the line in code below:
String result = (String)call.invoke(params);
I encounter the following error (unexpected encoding style), which I am
trying to discern the cause of. I have enclsoed the call stack to the error,
followed by the code that is causing the problem. TIA, Ike
unexpected encoding style:
expected=http://schemas.xmlsoap.org/soap/encoding/, actual=
at
com.sun.xml.rpc.encoding.SOAPDeserializationContext.verifyEncodingStyle(SOAP
DeserializationContext.java:160)
at
com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBa
se.java:148)
at
com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(Referenceab
leSerializerImpl.java:141)
at
com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvoker
Impl.java:225)
at
com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:168)
at
com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:64)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:346)
at dii.HelloClient.main(HelloClient.java:162)
-----------------------
package dii;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;
public class HelloClient {
private static String qnameService = "DOTSGeoPhone";//<service
name="InstantMessageAlert">
private static String qnamePort = "DOTSGeoPhoneSoap";//<portType
name="InstantMessageAlertSoap">
private static String BODY_NAMESPACE_VALUE = "urn:Foo";
private static String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
private static String NS_XSD = "http://www.w3.org/2001/XMLSchema";
private static String URI_ENCODING =
"http://schemas.xmlsoap.org/soap/encoding/";
public static void main(String[] args) {
String
endpoint="http://ws2.serviceobjects.net/gp/GeoPhone.asmx";//<soap:address>
System.out.println("Endpoint address = " + endpoint);
try {
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new
QName(qnameService));
QName port = new QName(qnamePort);
Call call = service.createCall(port);
call.setTargetEndpointAddress(endpoint);
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new
Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY,
"http://www.serviceobjects.com/GetPhoneInfo" );
call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
call.setReturnType(QNAME_TYPE_STRING);
call.setOperationName(new
QName(BODY_NAMESPACE_VALUE,"GetContactInfo "));//the method we call
call.addParameter("PhoneNumber", QNAME_TYPE_STRING,
ParameterMode.IN);
call.addParameter("LicenseKey", QNAME_TYPE_STRING,
ParameterMode.IN);
String[] params = {"440 247 1962" ,"MyLicenseKey"};
String result = (String)call.invoke(params);
System.out.println(result);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
from Sun, and altering the values for the webservice
DOTSGeoPhone:GetPhoneInfo described at
http://ws2.serviceobjects.net/gp/GeoPhone.asmx?op=GetPhoneInfo
I am getting an "unexpected encoding style," error
when it gets to the line in code below:
String result = (String)call.invoke(params);
I encounter the following error (unexpected encoding style), which I am
trying to discern the cause of. I have enclsoed the call stack to the error,
followed by the code that is causing the problem. TIA, Ike
unexpected encoding style:
expected=http://schemas.xmlsoap.org/soap/encoding/, actual=
at
com.sun.xml.rpc.encoding.SOAPDeserializationContext.verifyEncodingStyle(SOAP
DeserializationContext.java:160)
at
com.sun.xml.rpc.encoding.ObjectSerializerBase.deserialize(ObjectSerializerBa
se.java:148)
at
com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.deserialize(Referenceab
leSerializerImpl.java:141)
at
com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvoker
Impl.java:225)
at
com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:168)
at
com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:64)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:346)
at dii.HelloClient.main(HelloClient.java:162)
-----------------------
package dii;
import javax.xml.rpc.Call;
import javax.xml.rpc.Service;
import javax.xml.rpc.JAXRPCException;
import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceFactory;
import javax.xml.rpc.ParameterMode;
public class HelloClient {
private static String qnameService = "DOTSGeoPhone";//<service
name="InstantMessageAlert">
private static String qnamePort = "DOTSGeoPhoneSoap";//<portType
name="InstantMessageAlertSoap">
private static String BODY_NAMESPACE_VALUE = "urn:Foo";
private static String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
private static String NS_XSD = "http://www.w3.org/2001/XMLSchema";
private static String URI_ENCODING =
"http://schemas.xmlsoap.org/soap/encoding/";
public static void main(String[] args) {
String
endpoint="http://ws2.serviceobjects.net/gp/GeoPhone.asmx";//<soap:address>
System.out.println("Endpoint address = " + endpoint);
try {
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new
QName(qnameService));
QName port = new QName(qnamePort);
Call call = service.createCall(port);
call.setTargetEndpointAddress(endpoint);
call.setProperty(Call.SOAPACTION_USE_PROPERTY, new
Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY,
"http://www.serviceobjects.com/GetPhoneInfo" );
call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
call.setReturnType(QNAME_TYPE_STRING);
call.setOperationName(new
QName(BODY_NAMESPACE_VALUE,"GetContactInfo "));//the method we call
call.addParameter("PhoneNumber", QNAME_TYPE_STRING,
ParameterMode.IN);
call.addParameter("LicenseKey", QNAME_TYPE_STRING,
ParameterMode.IN);
String[] params = {"440 247 1962" ,"MyLicenseKey"};
String result = (String)call.invoke(params);
System.out.println(result);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}