You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Eric Seifert <es...@waca.com> on 2004/02/25 17:27:16 UTC

Can someone help

I'm trying to access a .net web service from a java client. I've tried it 2
different ways. One way is in the code below which gives me this error: 
System.Web.Services.Protocols.SoapException: Server was unable to read
request. ---> System.InvalidOperationException: There is an error in XML
document (4, 2). ---> System.InvalidOperationException: <StringTest
xmlns='http://tempuri.org/'> was not expected.

The other way is that I downloaded the jbuilderx trial and tried using the
axis emitter that the ide uses to auto generate the stub classes then used
those to make a call to the the web service and I get this error:
System.Web.Services.Protocols.SoapException: Server did not recognize the
value of HTTP Header SOAPAction: http://tempuri.org/rpc.

I've changed my .net web service numerous times and still can't seem to get
it to work. Even followed the instructions on the msdn site for integration
with java and that didn't help any. Can someone help me out please. Thanks.
Eric


	public void sendXMLString()
	{
		System.out.println("SendXML.sendXMLString()");
		try {
			System.out.println("here we go again...");
			URL url = new URL
("http://wcatl64/WaCA/WSTest/Service1.asmx");

			SOAPMappingRegistry smr = new SOAPMappingRegistry
();
			StringDeserializer sd = new StringDeserializer ();
			QName qn = new QName("http://tempuri.org/",
"StringTestResult");
			smr.mapTypes( Constants.NS_URI_SOAP_ENC, qn, null,
null, sd );

			// create the transport and set parameters
			SOAPHTTPConnection st = new SOAPHTTPConnection();

			// build the call.
			Call call = new Call ();
			call.setSOAPTransport(st);
			call.setSOAPMappingRegistry (smr);

			call.setTargetObjectURI ("http://tempuri.org/");
			call.setMethodName("StringTest");
			call.setEncodingStyleURI( Constants.NS_URI_SOAP_ENC
);

			Vector params = new Vector();
			params.addElement( new Parameter(
"StringTestResult", String.class, "hello world", null ) );
			call.setParams(params);

			Response resp = null;
			resp = call.invoke (url, "http://tempuri.org/rpc");
			System.out.println(" ");
			System.out.println("****");
			System.out.println("resp.generatedFault() value:
"+resp.generatedFault());
			if ( !resp.generatedFault() )
			{
				System.out.println("1");
				Parameter ret = resp.getReturnValue();
				System.out.println("2");
				Object value = ret.getValue();
				System.out.println("3");
				System.out.println("value:  "+value);
				System.out.println("4");
			}
			else
			{
				Fault fault = resp.getFault();
				System.err.println("Generated fault: ");
				System.out.println ("  Fault Code   = "
									+
fault.getFaultCode());
				System.out.println ("  Fault String = "
									+
fault.getFaultString());
			}
			System.out.println("****");
			System.out.println(" ");
		}
		catch (SOAPException e) {
			System.err.println("Caught SOAPException (" +
e.getFaultCode () + "): " + e.getMessage ());
			return;
		}
		catch ( MalformedURLException urlE )
		{
			System.err.println("MalformedURLException -
SendXML.sendXMLString - message");
		}

	}