Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

document based web service client, problem

843833Nov 6 2005
I am writing a simple document based web service client, the wsdl is: http://www50.brinkster.com/vbfacileinpt/np.asmx?wsdl

I wrote a GetPrimeNumbers class with a String member Max.

Here is the code fragment to consume the service:

URL wsdlURL = new URL("http://www50.brinkster.com/vbfacileinpt/np.asmx?wsdl");
String targetNS = "http://www50.brinkster.com/vbfacileinpt/np";
QName serviceQname = new QName(targetNS, "pnum");
Service s = sf.createService(wsdlURL, serviceQname);
QName portQname = new QName(targetNS, "pnumSoap");
QName opName = new QName("pnumSoap", "GetPrimeNumbers");

Call call = s.createCall(portQname, opName);
call.setProperty(call.SOAPACTION_USE_PROPERTY, new Boolean(true));
call.setProperty(call.SOAPACTION_URI_PROPERTY, "http://www50.brinkster.com/vbfacileinpt/np/GetPrimeNumbers");

GetPrimeNumbersResponse resp = (GetPrimeNumbersResponse)call.invoke (new Object[]{new GetPrimeNumbers("999")});

But I got error:

unexpected XML reader state. expected: END but found: START: {http://www50.brinkster.com/vbfacileinpt/np}GetPrimeNumbersResult

Checking my SOAP request, I found my SOAP message is:

<?xml version="1.0" encoding="UTF-8"?>..

<env:Envelope xmlns: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:enc="http://schemas.xmlsoap.org/soap/encoding/">

<env:Body>

<ans1:GetPrimeNumbers xmlns:ans1="http://www50.brinkster.com/vbfacileinpt/np">

<Max>50</Max>

</ans1:GetPrimeNumbers>

</env:Body>

</env:Envelope>

When I add target Namespace to Max, it will work fine.

But since GetPrimeNumbers will be serialized automatically, how can I add the name space to Max?

Thanks for any response!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 4 2005
Added on Nov 6 2005
0 comments
108 views