Home > Net >  .net invokes the Java WSDL interface
.net invokes the Java WSDL interface

Time:09-17

The interface address http://XXXXXXXXXX/CService/services/CgService? WSDL
In this interface has a method called SendFile, this method has two parameters (is string type is a file name, one is XML,)
SendFile (string fileName, XML string)


I want to use HttpWebRequest and HttpWebResponse call directly, could you tell me how to write,

Public string SendExpertResult (string postUrl, string fileName , string strXML)//-- - how do you pass this fileName
{
String ret=string. The Empty;
Try
{
Byte [] byteArray containing=Encoding. UTF8. GetBytes (strXML);//convert
HttpWebRequest webReq=(HttpWebRequest) WebRequest. Create (new Uri (postUrl));
WebReq. Method="POST";
WebReq. ContentType="application/json; Charset=utf-8 ";//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- whether you need this piece into XML format
WebReq. ContentLength=byteArray containing. Length;
The Stream newStream=webReq. GetRequestStream ();
NewStream. Write (byteArray containing, 0, byteArray containing. Length);//in parameter
NewStream. Close ();
HttpWebResponse response=(HttpWebResponse) webReq. The method GetResponse ();
StreamReader sr=new StreamReader (response. GetResponseStream (), Encoding, UTF8);
Ret.=the sr ReadToEnd ();
The sr. The Close ();
The response. The Close ();
NewStream. Close ();
return ret;
}
The catch (Exception ex)
{
Return the ex. The Message;
}

}

CodePudding user response:

FileName=xxx& XML=XXX
Use & amp; together

CodePudding user response:

Add Web reference point to the WSDL file, and then call the local library as used directly by the method

CodePudding user response:

But not necessarily can do it with the Post and Get words, the other party does not necessarily support, if the other party support this way need to
Byte [] byteArray containing=Encoding. UTF8. GetBytes (strXML)
Here all the required parameters according to the "1=1 & amp; Parameter=value 2 & amp; Parameter 3=value 3... "The way to byteArray containing it
  • Related