Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
stephenalistoun
Posts: 17
Registered: ‎07-16-2012
My Device: None

Keep getting error unexepected type in SoapUI

Hi All,

 

I'm trying to connect to a webservice in .NET but keep getting the error "unexepected type".

 

The soap envelope that i get from httptransport.requestDump works perfectly fine in SoapUI, so what could i being doing wrong.

 

Stephen.

 

 

 

Code Example:

 

String soap_action = "http://tempuri.org/IAuthentication/Authenticate";

SoapObject request = new SoapObject("http://tempuri.org/", "Authenticate");

MapAuthenticationHeader authHeader = new MapAuthenticationHeader();
authHeader.code = "0E678274-8BE8-4039-8185-1C3D274E91E7";
authHeader.messageid = "111";
authHeader.partner = "Met";

MapAuthenticationRequest authRequest= new MapAuthenticationRequest();
authRequest.handset = "mobile";
authRequest.username = "salistoun@methys.com";
authRequest.password = "m#thy";

PropertyInfo piHeader = new PropertyInfo();
piHeader = new PropertyInfo();
piHeader.name = "header";
piHeader.type = MapAuthenticationHeader.MAPAUTHENTICATIONHEADER_CLASS;

PropertyInfo piRequest = new PropertyInfo();
piRequest = new PropertyInfo();
piRequest.name = "request";
piRequest.type = MapAuthenticationRequest.MAPAUTHENTICATIONREQUEST_CLASS;
request.addProperty(piHeader , authHeader); 
request.addProperty(piRequest , authRequest); 

// Build envelope , 
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12);// Soap version must match server implementation
envelope.dotNet = true; // Must set this if the server is implemented on the dotnet framework
envelope.implicitTypes = true;
envelope.encodingStyle = "utf-8";
envelope.enc = "http://www.w3.org/2005/08/addressing";
envelope.env = "http://www.w3.org/2003/05/soap-envelope";

envelope.addMapping("http://tempuri.org/", "header", MapAuthenticationHeader.MAPAUTHENTICATIONHEADER_CLASS);
envelope.addMapping("http://tempuri.org/", "request", MapAuthenticationRequest.MAPAUTHENTICATIONREQUEST_CLASS);
envelope.headerOut = new Element[4];
envelope.headerOut[0] = buildActionHeaderSetupDevice();
envelope.headerOut[1] = buildMessageIDHeaderSetupDevice();
envelope.headerOut[2] = buildReplyToHeaderSetupDevice();
envelope.headerOut[3] = buildToHeaderSetupDevice();

//envelope.bodyOut = request;
envelope.setOutputSoapObject(request);

HttpTransport ht = new HttpTransport("http://197.15.194.139:83/Webservice/Auth.svc");
ht.debug = true; 
System.out.println("First Stage");
System.out.println(ht.requestDump);
System.out.println(ht.responseDump);
System.out.println("End First Stage");
StringBuffer result = new StringBuffer();
try {
ht.call(soap_action, envelope);
} catch (IOException e) {
result.append("Error Message:");
result.append(e.getMessage());
result.append("Request Dump:");
result.append(ht.requestDump);
result.append("Response Dump:");
result.append(ht.responseDump); 

} catch (XmlPullParserException e) {
result.append("Error Message:");
result.append(e.getMessage());
result.append("Request Dump:");
result.append(ht.requestDump);
result.append("Response Dump:");
result.append(ht.responseDump); 
}

 

Please use plain text.
Developer
simon_hain
Posts: 16,137
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Keep getting error unexepected type in SoapUI

i would suggest to use HttpTransportSE with a java SE project, for example with JUnitTests, we develop our whole webservice code with this approach as it delivers better debugging and MUCH faster startup times.

also helpful is tcpmon to see the actual http traffic, and soapUI to create correct requests and spot potential mapping errors.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.