在c#中使用的Java webservice? [英] Java webservice consuming in c#?
本文介绍了在c#中使用的Java webservice?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C#应用程序中使用JAVA Web服务。我想用XML生成请求对象,如下所示。
I am consuming JAVA web service in C# application. I want to generate request object in XML like below.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="http://webservice.api.cabaret.com/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<soapenv:Header/>
<soapenv:Body>
<web:callArgs>
<name></name>
<args>
<entries>
<name>locator.content</name>
<value xsi:type="xs:string">AA==</value>
</entries>
<entries>
<name>locator.name</name>
<value xsi:type="xs:string">Reha0850.pdf</value>
</entries>
</args>
</web:callArgs>
</soapenv:Body>
</soapenv:Envelope>
但我的XML生成如下。
But my XML generate like below.
{<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<callArgs xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/PDFFieldReader.SignLiveSrv">
<PropertyChanged xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.ComponentModel" i:nil="true" />
<argsField>
<mapEntry>
<PropertyChanged xmlns:d6p1="http://schemas.datacontract.org/2004/07/System.ComponentModel" i:nil="true" />
<nameField>locator.content</nameField>
<valueField xmlns:d6p1="http://www.w3.org/2001/XMLSchema" i:type="d6p1:base64Binary">AA==</valueField>
</mapEntry>
</argsField>
<nameField>urn:callArgs</nameField>
</callArgs>
</s:Body>
</s:Envelope>}
我使用以下类作为存根并序列化它们。
I used the following classes as a stub and serialize them.
namespace PDFFieldReader.SignLiveSrv {
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1064.2")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservice.api.cabaret.com/")]
public partial class mapEntry : object, System.ComponentModel.INotifyPropertyChanged {
private string nameField;
private object valueField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
this.RaisePropertyChanged("name");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
public object value {
get {
return this.valueField;
}
set {
this.valueField = value;
this.RaisePropertyChanged("value");
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.6.1064.2")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservice.api.cabaret.com/")]
public partial class callArgs : object, System.ComponentModel.INotifyPropertyChanged {
private string nameField;
private mapEntry[] argsField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=0)]
public string name {
get {
return this.nameField;
}
set {
this.nameField = value;
this.RaisePropertyChanged("name");
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, Order=1)]
[System.Xml.Serialization.XmlArrayItemAttribute("entries", Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
public mapEntry[] args {
get {
return this.argsField;
}
set {
this.argsField = value;
this.RaisePropertyChanged("args");
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
}
我尝试了什么:
我使用频道编程来调用webservice如下。
What I have tried:
I am using channel programming to call the webservice as below.
IChannelFactory<IRequestChannel> factory = binding.BuildChannelFactory<IRequestChannel>(bindingParams);
factory.Open();
EndpointAddress endPointAddress = new EndpointAddress("http://10.32.137.65:8888/SignatureService/"); IRequestChannel channel = factory.CreateChannel(endPointAddress);
channel.Open();
System.ServiceModel.Channels.Message requestMessage = System.ServiceModel.Channels.Message.CreateMessage(MessageVersion.Soap11, "urn:callArgs", objMapEntry);
以上CreateMessage没有给我上面提到的肥皂消息。
请帮我解决这个问题。
谢谢&此致,
Suraj
Above CreateMessage not giving me the expected soap message mentioned above.
Please help me out to resolve this .
Thanks & Regards,
Suraj
推荐答案
使用.NET客户端使用Java Web服务 [ ^ ]
这篇关于在c#中使用的Java webservice?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文