I am trying to consume the following WSDL in VS2010 and Im running into errors which seem to be specific to the WSDL.
I am adding it as a Web Service Reference, and initially no proxy classes or anything are created - the wizard completes successfully and I get a .wsdl and a Reference.map file under ~/Web References/ in the project, however the service is unavailable in code.
If I do an "Update Web Reference" on it, I get the following error:
Custom tool error: Unable to import WebService/Schema. The element attribute is not allowed on encoded message parts. The erroneous part is named 'textReturnObject' in message 'singleTextResponse'. (File: Reference.map line 1 column 1)
If I try and rename "element" to "type" i get a whole bunch of other issues:
The custom tool 'MSDiscoCodeGenerator' failed. Cannot find definition for http://schemas.xmlsoap.org/wsdl/:exampleServiceNameBinding. Service Description with namespace http://schemas.xmlsoap.org/wsdl/ is missing.
Parameter name: name
Can anyone shed any light on it? I've put the WSDL through some online tools and they consume it fine - does VS2010 have an issue with certain types of WSDL?
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.com/exampleServiceName" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" name="exampleServiceName" targetNamespace="http://www.example.com/exampleServiceName" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<xsd:complexType name="exampleType">
<sequence>
<element minOccurs="1" maxOccurs="1" name="title" type="string" />
<element minOccurs="1" maxOccurs="1" name="url" type="string" />
<element minOccurs="1" maxOccurs="1" name="description" type="string" />
</sequence>
</xsd:complexType>
<wsdl:types />
<wsdl:message name="singleTextRequest">
<wsdl:part name="intIdentity" type="xsd:integer" />
</wsdl:message>
<wsdl:message name="singleTextResponse">
<wsdl:part name="textReturnObject" element="wsdl:exampleType" />
</wsdl:message>
<wsdl:portType name="exampleServiceNamePortType">
<wsdl:operation name="singleTextAdvert">
<wsdl:input message="tns:singleTextRequest" />
<wsdl:output message="tns:singleTextResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="exampleServiceNameBinding" type="tns:exampleServiceNamePortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc" />
<wsdl:operation name="singleText">
<soap:operation soapAction="urn:xmethods-delayed-quotes#singleText" />
<wsdl:input>
<soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="exampleServiceNameService">
<wsdl:port name="exampleServiceNamePort" binding="wsdl:exampleServiceNameBinding">
<soap:address location="http://www.example.com/exampleServiceName/Server.php" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
I have a question on SO where I had trouble adding a service reference. I ended up using svcutil as recommended and it solved the problem. My situation was slightly different, but it's worth a try.
.net web service: Can't add service reference, only web reference
Yes, VS2010 can't create a web service reference from some WSDLs. Have to write custom wrapper for those. OR edit your WSDL in a way so VS can consume it. For example it may be ok for you to remove web service method references for the methods that you are not planning to use if those references create trouble for you.
Related
I'm trying to add a Service Reference to my project and I'm getting constantly the same error.
I've created a mock service with SOAP UI that seems fine, then I try to add a service reference to this mock service and the error appears:
Warning 14 Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'urn:oasis:names:tc:dss:1.0:core:schema' could not be found.
XPath to Error Source: //wsdl:definitions[#targetNamespace='http://tempuri.org/esign']/wsdl:portType[#name='EsignServiceSoap11PortType']
The import on the wsdl where schema with namespace urn:oasis:names:tc:dss:1.0:core:schema is being loaded is:
<wsdl:types>
<schema xmlns="urn:oasis:names:tc:dss:1.0:core:schema">
<import namespace="urn:oasis:names:tc:dss:1.0:core:schema" schemaLocation="oasis-dss-core-schema-v1.0-os.xsd"/>
</schema>
.....
</wsdl:types>
I've already tried to link the schemaLocation directly to the file in the same folder than the wsdl, to a url where it's published in a private server and to a public uri where it's also published.
I get always the same error and I'm starting to feel that maybe I'm mistaken with the source of the problem.
Any insight will be much appreciated.
UPDATE: I've injected urn:oasis:names:tc:dss:1.0:core:schema complete definition inside my wsdl file, instead of trying to import it. When I do so, SOAP UI still creates correctly the mocking service, however, when I try to add a Service Reference, this error is thrown during service discovery:
The document was understood, but it could not be processed.
- The WSDL document contains links that could not be resolved.
- DTD is prohibited in this XML document.
Metadata contains a reference that cannot be resolved: 'http://elite8100-3:8088/mockEsignServiceSoap11Binding?WSDL'.
The content type text/html; charset=iso-8859-1 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 455 bytes of the response were: '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>Server</soap:Value>
</soap:Code>
<soap:Reason>
<!--1 or more repetitions:-->
<soap:Text xml:lang="en">Missing operation for soapAction [null] and body element [null] with SOAP Version [SOAP 1.2]</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.
EDIT2: I've used Fiddler to check http traffic when trying to create the proxy, as suggested in the answer. During the creation, a 500 internal server error appears on Fiddler when trying to reach the mockService url, the response from the server was "Missing operation for soapAction [null] and body element [null] with SOAP version [SOAP 1.2]".
This is, currently, the WSDL I'm using to create the mockService.
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://www.w3.org/2001/XMLSchema" schemaLocation="http://aplicaciones.serpasa.es/CONTROLAMBIENTAL/oasis-dss-core-schema-v1.0-os.xsd"/>
</schema>
<schema xmlns="http://princast.es/esign/2.0/esign.xsd">
<import namespace="http://princast.es/esign/2.0/esign.xsd" schemaLocation="http://aplicaciones.serpasa.es/CONTROLAMBIENTAL/esign.xsd"/>
</schema>
</wsdl:types>
<wsdl:message name="SignRequestMessage">
<wsdl:part element="dss:SignRequest" name="payload"/>
</wsdl:message>
<wsdl:message name="SignResponseMessage">
<wsdl:part element="dss:SignResponse" name="payload"/>
</wsdl:message>
<wsdl:message name="VerifyRequestMessage">
<wsdl:part element="dss:VerifyRequest" name="payload"/>
</wsdl:message>
<wsdl:message name="VerifyResponseMessage">
<wsdl:part element="dss:VerifyResponse" name="payload"/>
</wsdl:message>
<wsdl:message name="GetSignInfoFromDocumentRequestMessage">
<wsdl:part element="esign:SignInfoRequest" name="payload"/>
</wsdl:message>
<wsdl:message name="GetSignInfoFromDocumentResponseMessage">
<wsdl:part element="esign:SignInfo" name="payload"/>
</wsdl:message>
<wsdl:message name="GetSignConfigurationRequestMessage">
<wsdl:part element="esign:SignConfigurationRequest" name="payload"/>
</wsdl:message>
<wsdl:message name="GetSignConfigurationResponseMessage">
<wsdl:part element="esign:SupportedSignConfiguration" name="payload"/>
</wsdl:message>
<!-- Port -->
<wsdl:portType name="EsignServiceSoap11PortType">
<wsdl:operation name="sign">
<wsdl:input message="impl:SignRequestMessage" name="signRequest"/>
<wsdl:output message="impl:SignResponseMessage" name="signResponse"/>
</wsdl:operation>
<wsdl:operation name="verify">
<wsdl:input message="impl:VerifyRequestMessage" name="verifyRequest"/>
<wsdl:output message="impl:VerifyResponseMessage" name="verifyResponse"/>
</wsdl:operation>
<wsdl:operation name="getSignConfiguration">
<wsdl:input message="impl:GetSignConfigurationRequestMessage" name="getSignConfigurationRequest"/>
<wsdl:output message="impl:GetSignConfigurationResponseMessage" name="getSignConfigurationResponse"/>
</wsdl:operation>
<wsdl:operation name="getSignInfoFromDocument">
<wsdl:input message="impl:GetSignInfoFromDocumentRequestMessage" name="getSignInfoFromDocumentRequest"/>
<wsdl:output message="impl:GetSignInfoFromDocumentResponseMessage" name="getSignInfoFromDocumentResponse"/>
</wsdl:operation>
</wsdl:portType>
<!-- Binding -->
<wsdl:binding name="EsignServiceSoap11Binding" type="impl:EsignServiceSoap11PortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="sign">
<wsdl:documentation>
Realiza una firma digital delegada sobre un
documento segun el estandard OASIS Digital Signature Service (DSS)
</wsdl:documentation>
<wsdlsoap:operation soapAction="urn:sign"/>
<wsdl:input name="signRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="signResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="verify">
<wsdl:documentation>
Verifica una firma digital OASIS Digital
Signature Service (DSS)
</wsdl:documentation>
<wsdlsoap:operation soapAction="urn:verify"/>
<wsdl:input name="verifyRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="verifyResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSignConfiguration">
<wsdl:documentation>
Obtiene los certificados con los que una
aplicacion en el MC de Firma Digital puede realizar
una firma
</wsdl:documentation>
<wsdlsoap:operation soapAction="urn:getSignConfiguration"/>
<wsdl:input name="getSignConfigurationRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getSignConfigurationResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="getSignInfoFromDocument">
<wsdl:documentation>
Obtiene informacion de un fichero de firma
</wsdl:documentation>
<wsdlsoap:operation soapAction="urn:getSignInfoFromDocument"/>
<wsdl:input name="getSignInfoFromDocumentRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getSignInfoFromDocumentResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EsignService">
<wsdl:documentation>
Servicio web de firma digital
</wsdl:documentation>
<wsdl:port binding="impl:EsignServiceSoap11Binding" name="EsignServiceSoap11Port">
<wsdlsoap:address location="http://someexternalsite.com"/>
</wsdl:port>
</wsdl:service>
I've downloaded every single .xsd associated and published them on a public server, also I've changed schemaLocations so they point to addresses on this public server, however, the problem seems to be related to WSDL structure.
The main issue before your update must be that your syntax is wrong. Where you say <schema xmlns="urn:oasis:names:tc:dss:1.0:core:schema"> the tool is expecting <schema xmlns="http://www.w3.org/2001/XMLSchema">. To simply import an external XSD file, the above default XML namespace fix it's all you need.
Schema imports/includes can be quite cluttered; for those cases, when one puts them inside of the WSDL, as you have suggested, it is easy to make mistakes, as it is not a simple case of just cut-and-paste. For example, some tools may have issues handling references that originally were based on xsd:include; chameleon includes cannot be reproduced inside a WSDL; and all your xsd:imports MUST NOT use the schemaLocation attribute.
To troubleshoot issues related to broken references, I strongly recommend the use of an HTTP debugger, such as Fiddler. It'll tell you at least what references you forgot to clean, or any HTTP headers that your mock solution does not set properly.
If the above still leaves you with some questions, you will have to post your modified WSDL.
I have a java webserver that I need to communicate with using a wsdl contract. I didn't built the server, and I don't have access to its source code. I built a c# application and I added the service reference to the wsdl contract using visual studio "add service reference". I paste the part of the wsdl I am interested in:
<wsdl:operation name="SOAPRequestItemHead" parameterOrder="SessionID searchitems">
<wsdl:input message="impl:SOAPRequestItemHeadRequest" name="SOAPRequestItemHeadRequest"/>
<wsdl:output message="impl:SOAPRequestItemHeadResponse" name="SOAPRequestItemHeadResponse"/>
</wsdl:operation>
<wsdl:operation name="SOAPRequestItemHead">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="SOAPRequestItemHeadRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://wrapper.soap.aplusb.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="SOAPRequestItemHeadResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.200.26:8888/tcdnc/services/fsw" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:message name="SOAPRequestItemHeadResponse">
<wsdl:part name="SOAPRequestItemHeadReturn" type="tns2:SOAPItemRevisionHeadResult"/>
</wsdl:message>
<complexType name="SOAPItemRevisionHeadResult">
<sequence>
<element maxOccurs="1" minOccurs="0" name="comment" nillable="true" type="xsd:string"/>
<element name="searchComplete" type="xsd:boolean"/>
<element maxOccurs="unbounded" minOccurs="0" name="search" type="tns2:StringMap"/>
<element maxOccurs="unbounded" minOccurs="0" name="resultList" type="tns2:SOAPItemRevisionHead"/>
</sequence>
</complexType>
Note that resultList and search are arrays. If I call this method, here is the raw response, taken with a SOAP tool:
<SOAPRequestItemHeadReturn xmlns:ns2="fsw" xsi:type="ns2:SOAPItemRevisionHeadResult">
<comment xsi:type="xsd:string" xsi:nil="true"/>
<searchComplete xsi:type="xsd:boolean">true</searchComplete>
<resultList xsi:type="ns2:SOAPItemRevisionHead">
<search xsi:type="ns2:StringMap">
<stringKey xsi:type="xsd:string">ItemRevision.ItemID</stringKey>
<stringValue xsi:type="xsd:string">cam_english_template</stringValue>
</search>
<search xsi:type="ns2:StringMap">
<stringKey xsi:type="xsd:string">ItemRevision.Revision</stringKey>
<stringValue xsi:type="xsd:string">A</stringValue>
</search>
<dummy xsi:type="xsd:string" xsi:nil="true"/>
</resultList>
<resultList xsi:type="ns2:SOAPItemRevisionHead">
...
As you see, resultList and search are actually arrays. But when I call the method from my c# client, I get this error:
Error in deserializing body of reply message for operation 'SOAPRequestItemHead'.
Inner Exception: There is an error in XML document (1, 815).
Inner Exception: Cannot assign object of type StringMap to an object of type StringMap[]
And if I go to the Reference.cs that is automatically generated, and I manually change the type of the two properties that are supposed to be arrays from StringMap[] to StringMap the error is not thrown, but of course I can only get the first item of the array in my program. I hope I was clear, even if it's a long question.
Update: I know this is a problem with using Axis 1.4, that uses rcp/encoded instead of document/literal, so the question can be reformulated in these terms: "can .NET correctly handle rcp/encoded?"
Check the data contracts generated by VS. They should contain specific type for the 'resultList' as well, decorated with CollectionDataContract attribute. I would also check whether the namespaces and names are set precisely on DataContract attributes.
EDIT: about RPC style web services you can find some workaround on these links:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/51babae5-26e5-4405-b03c-4301710854c0/why-does-add-service-reference-fail-to-build-a-proper-reference-for-dfa?forum=wcf
http://social.msdn.microsoft.com/Forums/vstudio/en-US/07edda1a-d0d5-4920-b2fb-a25c803269d6/trouble-with-consuming-a-java-rpc-web-service-using-net-client?forum=wcf
As far I can see, something is wrong in SOAPItemRevisionHeadResult type definition in th WSDL.
<complexType name="SOAPItemRevisionHeadResult">
<sequence>
<element maxOccurs="1" minOccurs="0" name="comment" nillable="true" type="xsd:string"/>
<element name="searchComplete" type="xsd:boolean"/>
<element maxOccurs="unbounded" minOccurs="0" name="search" type="tns2:StringMap"/>
<element maxOccurs="unbounded" minOccurs="0" name="resultList" type="tns2:SOAPItemRevisionHead"/>
</sequence>
</complexType>
A type with this definition maps to:
Public class SOAPItemRevisionHeadResult{
public string comment;
public boolean searchComplete;
public Stringmap[] search;
public SOAPItemRevisionHead[] resultList;
}
Public class StringMap{
//can't see definition of this type in your part of WSDL posted but doesn't matter.
//guesed definition by looking at the response
public string StringKey;
public string StrigValue;
//end of guesed definition
}
Public class SOAPItemRevisionHead{
//can't see definition of this type in your part of WSDL posted but doesn't matter.
//guesed definition by looking at the response
public StringMap[] search;
//end of guesed definition
}
Seems bad nesting classes in WSDL but in the Raw Response you posted I can see the correct nesting:
Public class SOAPItemRevisionHeadResult{
public string comment;
public boolean searchComplete;
public resultList as SOAPItemRevisionHead[];
}
Public class SOAPItemRevisionHead{
public StringMap[] search;
}
Public class StringMap{
public string StringKey;
public string StrigValue;
}
Possibly you want to consider an alternative to that encoding if possible, see:
http://security-world.blogspot.dk/2005/07/nt-aspnet-rcpencoded-web-service-dos.html
I believe the answer you're searching for is in this post:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/51babae5-26e5-4405-b03c-4301710854c0/why-does-add-service-reference-fail-to-build-a-proper-reference-for-dfa?forum=wcf
Corrected link above, don't know why the wrong one got in there
I am new to WCF and I wrote some service in wcf. It is now published on the Intranet and some applications are already using that service. At the moment, I have to make the documentation about the input parameters / data type and output parameters for other developers. It is ok, if we use .Net platform to consume the service. It automatically creates the services/classes in the WebReferences folder and Intellisense work perfectly.
But if the user is using PHP or classic ASP, it doesn't work that way. They have to know exact name, type of the parameters and I have to document the services very carefully.
By using WSDL as below: how can we know the datatype and parameters of the service we want to use? If it doesn't show in WSDL, where should I look at these information? If someone gave me WCF service without documentation, how could I know how to use that service?
Thanks very much.
This following is my Interface about the Service
[ServiceContract]
public interface IEmail
{
[OperationContract]
bool InsertEmail(string Subject, string SentFrom, string SentTo, int ApplicationID, int TemplateID, string DataText);
}
The following is the exact WSDL info about my service.
<?xml version="1.0" encoding="utf-8" ?>
- <wsdl:definitions name="Email" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
- <wsdl:types>
- <xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd0" namespace="http://tempuri.org/" />
<xsd:import schemaLocation="http://myservice/Email.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
</xsd:schema>
</wsdl:types>
- <wsdl:message name="IEmail_InsertEmail_InputMessage">
<wsdl:part name="parameters" element="tns:InsertEmail" />
</wsdl:message>
- <wsdl:message name="IEmail_InsertEmail_OutputMessage">
<wsdl:part name="parameters" element="tns:InsertEmailResponse" />
</wsdl:message>
- <wsdl:portType name="IEmail">
- <wsdl:operation name="InsertEmail">
<wsdl:input wsaw:Action="http://tempuri.org/IEmail/InsertEmail" message="tns:IEmail_InsertEmail_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IEmail/InsertEmailResponse" message="tns:IEmail_InsertEmail_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="BasicHttpBinding_IEmail" type="tns:IEmail">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="InsertEmail">
<soap:operation soapAction="http://tempuri.org/IEmail/InsertEmail" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="Email">
- <wsdl:port name="BasicHttpBinding_IEmail" binding="tns:BasicHttpBinding_IEmail">
<soap:address location="http://myservice/Email.svc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
If you mean that you can't see all the types your service uses in the WSDL, this is because the WSDL WCF creates is often (maybe always) split into several bits. These other bits are linked to from the main WSDL.
So if you browse to http://myservice/Email.svc?wsdl, you'll see the WSDL you've put in your question. In here, you can see links to two other schemas - http://myservice/Email.svc?xsd=xsd0 and http://myservice/Email.svc?xsd=xsd1. If you browse to these, you'll find the type information you're looking for.
I am using Visual studio 2008 C# Windows application to connect to a webservice created by an external company. The service is a WSDL url, which is a basic soap request and response. I have inported the service as a service reference. I can call the service, and receive no errors, but the reponse is nothing. When monitoring the soap request and response in Fiddler, i see a response coming back, but it's as if VS cannot interpret the response. I have looked at creating xsd's, but get an error stating that there's already a schema. So I am at a total loss. I hope someone can help. I apologise if this exact issue has been solved before, but i cannot find anything that resolves my problem.
Thanks in advance!
The code I am using to connect to the service is as follows:
ServiceReference1.bpm bbb = new TestingWSDL.ServiceReference1.bpm();
ServiceReference1.BPMExternalAppServicesV001Client soapClient = new TestingWSDL.ServiceReference1.BPMExternalAppServicesV001Client();
ServiceReference1.DownloadShipmentDataV001 req = new TestingWSDL.ServiceReference1.DownloadShipmentDataV001();
ServiceReference1.DownloadShipmentDataV001Response resp = new TestingWSDL.ServiceReference1.DownloadShipmentDataV001Response();
try
{
soapClient.DownloadShipmentDataV001(req,out resp);
}
catch(Exception err)
{
MessageBox.Show(err.Message);
}
the response object does not have any data in. I cannot post an image, as i am not allowed.
The WSDL is quite long and is as follows:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tns="http://schemas.ccc.com/AROPInventory/bpm/external" xmlns:inst="http://schemas.aaa.com/bpm/instance/1.0" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" name="BPMExternalAppServicesV001" targetNamespace="http://schemas.ccc.com/AROPInventory/bpm/external" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema xmlns:tns1="http://schemas.ccc.com/AROPInventory/bpm/external" xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.argility.com/AROPInventory/bpm/external" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://schemas.aaa.com/bpm/instance/1.0" />
<xsd:element name="UploadShipmentDataV001">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:Shipments" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" name="Shipments">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Shipment">
<xsd:complexType>
<xsd:sequence>
<xs:element name="ShipmentNumber" type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
<xsd:element name="Cartons">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="Carton">
<xsd:annotation>
<xsd:documentation>0:not damaged 1:damaged 2: Rejected0:not damaged 1:damaged 2: Rejected0:not damaged 1:damaged 2: Rejected</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xs:element name="CartionID" type="xs:byte" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
<xs:element name="Status" type="xs:byte" xmlns:xs="http://www.w3.org/2001/XMLSchema" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="TestUploadShipMentV001">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:Shipments" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="TestUploadShipMentV001Response" />
<xsd:element name="UploadShipmentDataV001Response" />
<xsd:element name="DownloadShipmentDataV001">
<xsd:complexType>
<xsd:sequence />
</xsd:complexType>
</xsd:element>
<xsd:element name="DownloadShipmentDataV001Response">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="tns1:Shipments" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.aaa.com/bpm/instance/1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="bpm">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="instance_id" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="DownloadShipmentDataV001Input">
<wsdl:part name="body" element="tns:DownloadShipmentDataV001" />
</wsdl:message>
<wsdl:message name="DownloadShipmentDataV001Output">
<wsdl:part name="body" element="tns:DownloadShipmentDataV001Response" />
</wsdl:message>
<wsdl:message name="HeaderOutput">
<wsdl:part name="BPMHeader" element="inst:bpm" />
</wsdl:message>
<wsdl:portType name="BPMExternalAppServicesV001">
<wsdl:operation name="DownloadShipmentDataV001">
<wsdl:input message="tns:DownloadShipmentDataV001Input" />
<wsdl:output message="tns:DownloadShipmentDataV001Output" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BPMExternalAppServicesV001" type="tns:BPMExternalAppServicesV001">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="DownloadShipmentDataV001">
<soap:operation soapAction="" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
<soap:header message="tns:HeaderOutput" part="BPMHeader" use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="BPMExternalAppServicesV001Service">
<wsdl:port name="BPMExternalAppServicesV001Port" binding="tns:BPMExternalAppServicesV001">
<soap:address location="http://aaa/aaa/com.eibus.web.soap.Gateway.wcp?organization=o=system,cn=aaa,cn=aaa,o=ho.bbb.co.za" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
The fiddler response is as follows:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
xmlns="http://schemas.aaa.com/General/1.0/">
<sender>
<reply-to>
cn=Business Process Management,cn=Business Process Management,cn=soap nodes,o=system,cn=aaa,cn=aaa20,o=ho.bbb.co.za
</reply-to>
<organizationalContext>o=system,cn=aaa,cn=aaa20,o=ho.bbb.co.za</organizationalContext>
<component>cn=Business Process Management,cn=soap nodes,o=system,cn=aaa,cn=aaa20,o=ho.bbb.co.za</component>
</sender>
<receiver>
<component>cn=webgateway#poc-aaa,cn=aaa,cn=aaa20,o=ho.bbb.co.za</component>
<sent-to xmlns="http://schemas.aaa.com/General/1.0/">socket://poc-aaa:20379/</sent-to>
</receiver>
<msg-id>00505680-004E-11E1-FBF1-7CB604BB1FC0</msg-id>
</header>
<bpm xmlns="http://schemas.aaa.com/bpm/instance/1.0">
<instance_id>26c34038-bea4-459c-a0ad-86b462ae90cb</instance_id>
</bpm>
</s:Header>
<s:Body>
<DownloadShipmentDataV001Response xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.argility.com/AROPInventory/bpm/external">
<Shipments xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.argility.com/AROPInventory/bpm/external">
<ShipmentHeader>
<ShipmentNumber>S001</ShipmentNumber>
<ReceivingBranch>B000028</ReceivingBranch>
<SendingBranch>B000001</SendingBranch>
<ExpectedDate>2012/07/30</ExpectedDate>
<TotalNrOfCartons>2</TotalNrOfCartons>
<ShipmentStatus>E</ShipmentStatus>
<Cartons>
<Carton>
<CartonHeader>
<NrOfItems>2</NrOfItems>
<CartionID>99</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12345</SKU>
<Description>abc</Description>
<SerialNumber>6789</SerialNumber>
<QtySent>20</QtySent>
<QtyReceived/>
</CartonDetail>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
<Carton>
<CartonHeader>
<NrOfItems>2</NrOfItems>
<CartionID>100</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12345</SKU>
<Description>abc</Description>
<SerialNumber>6789</SerialNumber>
<QtySent>20</QtySent>
<QtyReceived/>
</CartonDetail>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
</Cartons>
</ShipmentHeader>
<ShipmentHeader>
<ShipmentNumber>S002</ShipmentNumber>
<ReceivingBranch>B000029</ReceivingBranch>
<SendingBranch>B000002</SendingBranch>
<ExpectedDate>2012/06/3</ExpectedDate>
<TotalNrOfCartons>21</TotalNrOfCartons>
<ShipmentStatus>E</ShipmentStatus>
<Cartons>
<Carton>
<CartonHeader>
<NrOfItems>3</NrOfItems>
<CartionID>91</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12345</SKU>
<Description>abc</Description>
<SerialNumber>6789</SerialNumber>
<QtySent>20</QtySent>
<QtyReceived/>
</CartonDetail>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
<Carton>
<CartonHeader>
<NrOfItems>1</NrOfItems>
<CartionID>97</CartionID>
</CartonHeader>
<CartonDetail>
<SKU>12390</SKU>
<Description>abc</Description>
<SerialNumber>67232</SerialNumber>
<QtySent>2</QtySent>
<QtyReceived/>
</CartonDetail>
</Carton>
</Cartons>
</ShipmentHeader>
</Shipments>
</DownloadShipmentDataV001Response>
</s:Body>
</s:Envelope>
Thanks for posting the response as collected by Fiddler. I am actually seeing more than one problem in the WSDL and in the response conformance to the WSDL datatypes.
First issue: WSDL consistency/completeness
Note that the input and output messages refer to tns:DownloadShipmentDataV001 and tns:DownloadShipmentDataV001Response, respectively. xmlns:tns="http://schemas.ccc.com/AROPInventory/bpm/external" is the relevant prefix:namespace binding in the context of the message definitions, thus the fully-qualified names of the request and response message elements are {http://schemas.ccc.com/AROPInventory/bpm/external}DownloadShipmentDataV001 and {http://schemas.ccc.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response, respectively.
By virtue of the targetNamespace="http://schemas.argility.com/AROPInventory/bpm/external" declaration, the fully-qualified name of the elements defined in the types section of the WSDL document are
{http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001 and {http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response. This is a problem because the actual types referred to in the message definitions are missing from the WSDL and any imported/included documents.
A stub generator should complain about this when trying to consume the WSDL.
The external company should really correct this issue, but you could copy the WSDL and make a tweak by declaring the namespace of the actual element from the types section and binding to a prefix, then using that prefix in the message definition (weakness being you have an extra step in keeping up with any changes in their service definition):
xmlns:fromtype="http://schemas.argility.com/AROPInventory/bpm/external"
...
<wsdl:message name="DownloadShipmentDataV001Input">
<wsdl:part name="body" element="fromtype:DownloadShipmentDataV001" />
</wsdl:message>
<wsdl:message name="DownloadShipmentDataV001Output">
<wsdl:part name="body" element="fromtype:DownloadShipmentDataV001Response" />
</wsdl:message>
Second issue: Response Message Does Not Match Schema
Assume that the WSDL was consistent and called out the fully-qualified datatype from the types section. The response message's fully-qualified element structure would then be expected to be something like:
{http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response
{http://schemas.argility.com/AROPInventory/bpm/external}Shipments
{http://schemas.argility.com/AROPInventory/bpm/external}Shipment
{http://schemas.argility.com/AROPInventory/bpm/external}ShipmentNumber
{http://schemas.argility.com/AROPInventory/bpm/external}Cartons
{http://schemas.argility.com/AROPInventory/bpm/external}Carton
...
However, the actual structure in the response message is:
{http://schemas.argility.com/AROPInventory/bpm/external}DownloadShipmentDataV001Response
{http://schemas.argility.com/AROPInventory/bpm/external}Shipments
{http://schemas.argility.com/AROPInventory/bpm/external}ShipmentHeader
{http://schemas.argility.com/AROPInventory/bpm/external}ShipmentNumber
...
Note that ShipmentHeader is never declared as an element in the WSDL types section and is not imported from another document. If the unmarshaller is using the datatype definition provided in the WSDL, it does not understand the ShipmentHeader or its subelements so probably would leave those out (as you are seeing).
The correction for this issue is to match up the datatype schema definition with the actual response from the service. Again, the external organization hosting the service should correct this (their service is not in compliance with the given WSDL), but you could again tweak locally with the same caveat about extra steps keeping 'your' wsdl in lock-step with their service.
I hope this helps and respond back with further questions.
You will still need to parse this XML file yourself.
We have a similar problem with IBM's Remedy software. Basically it is terrible software and this behavior should be expected. Even if they update the code to match they are not generating the WSDL from the actual XML document they are generating... this problem will continue until they change their methods and you have no control over that.
I had a similar problem with empty answer but in fiddler it said the opposite. I fixed it by removing the
`System.ServiceModel.XmlSerializerFormatAttribute attribute and was able to serialize the response. Not the optimal solution but it worked for me.
How can I add a XML prefix to fields in WCF Message Serialization?
I'm connecting up to a Java Spring web service from .NET, and an object that I pass in with parameters is being serialized as you would expect:
<MyClass>
<field1>Field 1 Value</field1>
<field2>Field 2 Value</field2>
</MyClass>
However, the web service requires that the class and fields are prefixed with a namespace, let's say namespace blah, so what I want is:
<blah:MyClass>
<blah:field1>Field 1 Value</blah:field1>
<blah:field2>Field 2 Value</blah:field2>
</blah:MyClass>
How can I make this happen in WCF? Is there a way to adjust the XML serialization attributes on my class?
Edit: WSDL for this particular entity is as follows (edited to remove business-specific field names, but everything else is the same):
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:sch0="http://www.domain.com/app/schemas/entityone" xmlns:sch1="http://www.domain.com/app/schemas/types" xmlns:sch2="http://www.domain.com/app/schemas/query" xmlns:sch3="http://www.domain.com/app/schemas/entitytwo" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.domain.com/app/schemas/entityone" targetNamespace="http://www.domain.com/app/schemas/entityone">
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:types="http://www.domain.com/app/schemas/types" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://www.domain.com/app/schemas/entityone" xmlns:tns="http://www.domain.com/app/schemas/entityone">
<import namespace="http://www.domain.com/app/schemas/types" />
<element name="TheClassName">
<complexType>
<sequence>
<element name="field1" type="string" />
<element name="field2" type="string" />
<element name="field3" type="string" />
<element name="field4" type="string" />
<element name="field5" type="string" />
<element name="field6" type="string" />
<element name="field7" type="string" />
<element name="field8" type="string" />
</sequence>
</complexType>
</element>
<wsdl:binding name="NameOfBindingHere" type="tns:ReturnTypeHere">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="OperationNameHere">
<soap:operation soapAction="" />
<wsdl:output name="ResponseTypeHere">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
I think you are confusing namespaces and prefixes. In your example Blah is the prefix and is a pointer (alias) to the namespace. In the document, you will see an attribute xmlns:blah="http://tempuri/your/namespace", the prefix is blah and the namespace is http://tempuri/your/namespace.
What the prefix is used does not matter to whomever consumes the document, as long as it points to the same exact namespace.
so
<blah:MyClass xmlns:blah="http://tempuri/your/namespace"></blah:MyClass>
is the exact same thing as
<blah1:MyClass xmlns:blah1="http://tempuri/your/namespace"></blah1:MyClass>
XML Schema does not require that what prefix should be used.
Aliostad's DataContract example is exactly how to define the namespace that the Data Contract Serializer will use. There is no way to define what prefix the DataContract Serializer will use, because whatever the prefix is doesn't matter. That is as long as the service consuming this XML is adheres to XML standards (and isn't something like a RegEx expression, and believe me I've seen plenty of cases where the consumer of the XML was a custom written text parser instead of using an XML parser and didn't grasp the concept of XML Namespaces and Infosets).
Try defining MyClass as:
DataContract(namespace="blah")
Class MyClass
{
[DataMember]
Field1 ...
[DataMember]
Field2 ...
}
UPDATE
This will not create the prefix but the prefix would not be needed if XML has the correct namespace and Java should work.